ejbc error 'ejbCreate must return the primary key type'


EJB programming & troubleshooting: ejbc error 'ejbCreate must return the primary key type'

  1. Hi

    When I try to deploy Container managed entity bean (example from chapter 9 of Mastering EJB book) in WLS 5.1, I get the following error. I just added hashCode(), equals() methods to the primary class.

    "[9.2.3] In EJB Product, the ejbCreate method: ejbCreate(java.lang.String,java.lang.String,java.lang.String,double) must return the primary key type."

    The signature for the ejbCreate is :

    public void ejbCreate(String productID, String name, String description, double basePrice) throws CreateException, RemoteException

    As per the book , for Container managed, ejbCreate need NOT return of type primary key. I appreciate your help as I could not figure out. May be it is a problem with Deployment descriptor.

    This is the ejb-jar.xml I am using.

    <?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'>

  2. Hi Srinivas,

    You need to have the PK class as the return type.

    From EJB 1.1 for entity beans that use container managed persistence you should return null.

  3. Thanks !!

  4. The home interface should return the PK class type whereas the implementation can return a String.
  5. The method signature MUST return the PK type although in the CMP implementation you just return a null pointer.

    Dave Wolf
    Internet Applications Division