File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes  Error: [ ejbFindByPrimaryKey ] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark " Error: [ ejbFindByPrimaryKey ]" Watch " Error: [ ejbFindByPrimaryKey ]" New topic
Author

Error: [ ejbFindByPrimaryKey ]

AmitCdac Grover
Greenhorn

Joined: Mar 30, 2005
Posts: 26
hi

i made the BMP bean. after compliation in deloy time when i when i say
tools -> verifier in j2ee 1.3.1 it will give me following faliure

1.

For [ EmpEntityBean ]
For EJB Class [ EmpEntityBean ] Finder method [ ejbFindByPrimaryKey ]
Error: A [ ejbFindByPrimaryKey ] method was found, but [ ejbFindByPrimaryKey ] return type must be the enterprise beans primary key type.

2.

For [ EmpEntityBean ]
Error: Transaction attributes must be specified for the methods defined in the home interface [ EmpEntityHome ]. Method [ create ] has no transaction attribute defined within this bean [ EmpEntityBean ].

3.

For [ EmpEntityBean ]
For Home interface [ EmpEntityHome ]
Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ EmpEntityHome ].


follwowing are my home interface and component interface

public interface EmpEntityHome extends EJBHome
{
public EmpEntity create(int employeeid,String first,String last) throws CreateException,RemoteException;

public EmpEntity findByPrimaryKey(EntityPK key) throws FinderException,RemoteException;

public Collection findByFirstName(String firstname) throws FinderException,RemoteException;
public Collection findByLastName(String lastname) throws FinderException,RemoteException;

public Collection findByEmpEmployeeId(int id) throws FinderException,RemoteException;

}

public interface EmpEntity extends EJBObject
{
public String getEmpFirstName() throws RemoteException;
public void setEmpFirstName(String FirstName) throws RemoteException;

public String getEmpLastName() throws RemoteException;
public void setEmpLastName(String LastName) throws RemoteException;

public int getEmpEmployeeId() throws RemoteException;
public void setEmpEmployeeId(int EmpId) throws RemoteException;

}

this is my bean find by primary key method

public EntityPK ejbFindByPrimaryKey(EntityPK pk) throws FinderException
{
PreparedStatement pstmt = null;
Connection conn = null;
Vector v = new Vector();

try
{
DSManager.getConnection();
System.out.println("ejbFindByPrimaryKey(" + pk + ") called");

pstmt = conn.prepareStatement("SELECT EMPID FROM EMPLOYEE WHERE EMPID = ?");
int id=Integer.parseInt(pk.toString());
pstmt.setInt(1,id);
ResultSet rs = pstmt.executeQuery();
rs.next();
return pk;
}
catch (Exception e)
{
throw new FinderException(e.toString());
}
finally
{
try { if (pstmt != null) pstmt.close(); }
catch (Exception e) {}
try { if (conn != null) conn.close(); }
catch (Exception e) {}
}
}


plz help me out how i solve this problem

regards

amit grover
Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
Why are you creating BMP Entity Bean?
Subhash Bhushan C
Ranch Hand

Joined: Jan 27, 2005
Posts: 106
I am not completely sure about these solutions.. hope they help. If you still face the same problem, pase the entire bean code here.


1.

For [ EmpEntityBean ]
For EJB Class [ EmpEntityBean ] Finder method [ ejbFindByPrimaryKey ]
Error: A [ ejbFindByPrimaryKey ] method was found, but [ ejbFindByPrimaryKey ] return type must be the enterprise beans primary key type.

The primary key class must be public, and must have a public constructor without parameters. All fields in the primary key class must be declared public. The names of the fields in the primary key must be a subset of the names of the container-managed fields.

2.

For [ EmpEntityBean ]
Error: Transaction attributes must be specified for the methods defined in the home interface [ EmpEntityHome ]. Method [ create ] has no transaction attribute defined within this bean [ EmpEntityBean ].

You have not specified a transaction attribute for the create() method of the entity bean. As per EJB rules, in case of an entity bean, you will have to specify transaction attributes for:
A. All methods of the component interface
B. remove() method from the EJBObject (or EJBLocalObject)
C. All of the home interface methods written by the Bean Provider, as well as the remove() metods from EJBHome (or EJBLocalHome).

The transaction attribute will be specified for the method in DD.

3.

For [ EmpEntityBean ]
For Home interface [ EmpEntityHome ]
Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ EmpEntityHome ].

Please check what you have specified for the PrimaryKeyClass in the descriptor, and see if the same has been specified as the lone argument for your findByPrimaryKey method in the bean.


Regards,<br />Subhash Bhushan.
AmitCdac Grover
Greenhorn

Joined: Mar 30, 2005
Posts: 26
thanks .... now problem is solved .there is something problem with my coding

regards

amit grover
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error: [ ejbFindByPrimaryKey ]
 
Similar Threads
problem in bmp deployment
Searching problem
Error while Deploying BMP bean
urgent
ejbLoad is not getting called