It's not a secret anymore!*
The moose likes BEA/Weblogic and the fly likes error in deploying CMP bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "error in deploying CMP bean" Watch "error in deploying CMP bean" New topic
Author

error in deploying CMP bean

Anima Agrawal
Greenhorn

Joined: Sep 16, 2002
Posts: 22
hello,
i have been trying to deploy CMP bean. I am getting the error
NoSuchFieldException. I fail to understand the cause of this problem.
my code is like this
Remote interface ----Student
--------------------
import java.rmi.RemoteException;
import javax.ejb.*;
public interface Student extends EJBObject
{
public String getID() throws RemoteException;
//public void setName(String nm) throws RemoteException;
//public String getName()throws RemoteException;
}
Home interface -----studentHome
--------------------------------
import java.rmi.RemoteException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
import javax.ejb.CreateException;
import java.util.Enumeration;
public interface studentHome extends EJBHome
{
public Student create(String id) throws CreateException,RemoteException;
//public Student create(String id,String nm)throws CreateException,RemoteException;
public Student findByPrimaryKey(String id) throws FinderException,RemoteException;
//public Enumeration findByName(String nm) throws FinderException;
}
beanclass----studentbean
-------------------------
import Student;
import studentHome;
import javax.ejb.EntityBean;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.*;
public class studentbean implements EntityBean
{
EntityContext ctx;
String id;
//String nm;
public void setEntityContext(EntityContext ct)
{
System.out.println("Entity Context Set");
ctx=ct;
}
public void unsetEntityContext()
{
System.out.println("Entity Context UnSet");
ctx=null;
}
public Student ejbCreate(String i) throws CreateException
{
this.id=new String (i);
//nm="";
return null;
}
public void ejbPostCreate(String id)
{
System.out.println("created with the id");
}
/*public Student ejbCreate(String id,String nm) throws CreateException
{
this.id=new String (id);
this.nm=new String(nm);
return null;
}
public void ejbPostCreate(String id,String nm)
{
System.out.println("created with the id and name");
}
public void setName(String nm)
{
this.nm=new String(nm);
}
public String getName()
{
return nm;
}*/
public String getID()
{
return id;
}
public void ejbRemove()
{
System.out.println("remove called");
}
public void ejbStore()
{
System.out.println("store called:");
}
public void ejbLoad()
{
System.out.println("Load called:");
}
public void ejbActivate()
{
System.out.println("Activate called:");
}
public void ejbPassivate()
{
System.out.println("Passivate called:");
}
}
ejb-jar.xml
---------------
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Student</ejb-name>
<home>studentHome</home>
<remote>Student</remote>
<ejb-class>studentbean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Student</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
weblogic-ejb-jar.xml
-----------------------
<?xml version="1.0"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC
"-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"
"http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd" >

<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Student</ejb-name>
<entity-descriptor>
<persistence>
<persistence-type>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>5.1.0</type-version>
<type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
</persistence-type>
<persistence-use>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>5.1.0</type-version>
</persistence-use>
</persistence>
</entity-descriptor>
<jndi-name>StudentBean</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

weblogic-cmp-rdbms-jar.xml
----------------------------
<!DOCTYPE weblogic-rdbms-jar PUBLIC
'-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB 1.1 RDBMS Persistence//EN'
'http://www.bea.com/servers/wls600/dtd/weblogic-rdbms11-persistence-600.dtd'>
<weblogic-rdbms-jar>
<weblogic-rdbms-bean>
<ejb-name>Student</ejb-name>
<data-source-name>examples-dataSource-demoPool</data-source-name>
<table-name>StudentTable</table-name>
<field-map>
<cmp-field>id</cmp-field>
<dbms-column>id</dbms-column>
</field-map>
</weblogic-rdbms-bean>
<create-default-dbms-tables>True</create-default-dbms-tables>
</weblogic-rdbms-jar>
can any body plz help me
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

hi
why this
<primkey-field>id</primkey-field>


Groovy
Anima Agrawal
Greenhorn

Joined: Sep 16, 2002
Posts: 22
i think this tag is to specify the primary key for the database. Well in after removing this tag i am getting the same error...........

i really don't what is wrong

Anima
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Hi Anima Agrawal,
My previous post was wrong.
I am sorry for that. Plz do not remove that tag.
The problem could be becoz u have not made the field id in bean class as public. Please do that
Anima Agrawal
Greenhorn

Joined: Sep 16, 2002
Posts: 22
thanx..yeah....that was the mistake .....i had not made field public ..............but there is one more problem i am facing if i deploy any bean which an error ....if i delete the entries in the config file and redeploy the bean with same name i keep on getting the same error msg but if change the name of the same jar i get different error msg .......what can be the reason
regards
anima
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in deploying CMP bean