ejbCreate for EJB 1.1 CMP question

Discussions

EJB programming & troubleshooting: ejbCreate for EJB 1.1 CMP question

  1. ejbCreate for EJB 1.1 CMP question (4 messages)

    I'm really getting confused on exactly how I should be utilizing ejbCreate and ejbPostCreate. Documentation has made it even more confusing. The code snippet is below. The error I get in deployment is "Incompatible type for =. Can't convert void to java.lang.String." Note my primary key is in the form of a String and defined in the DD.
    Any help would be MOST appreciated:

     public String ejbCreate(long ID, String deptCode, String deptDesc,
        String groupCode, String groupDesc, String deptGlMask,
        String dsUpdDate, String dsUpdUser) throws CreateException, RemoteException {
        this.ID = ID;
        this.deptCode = deptCode;
        this.deptDesc = deptDesc;
        this.groupCode = groupCode;
        this.groupDesc = groupDesc;
        this.deptGlMask = deptGlMask;
        this.dsUpdDate = dsUpdDate;
        this.dsUpdUser = dsUpdUser;
        return null;
      }

      public String ejbCreate(long ID, String deptCode,
        String deptDesc) throws CreateException, RemoteException {
        this.ID = ID;
        this.deptCode = deptCode;
        this.deptDesc = deptDesc;
        return null;
      }

      public void ejbPostCreate(long ID, String deptCode, String deptDesc,
        String groupCode, String groupDesc, String deptGlMask,
        String dsUpdDate, String dsUpdUser) throws CreateException
      {
        //get primary key
        String pk = (String)ctx.getPrimaryKey();
      }

       public void ejbPostCreate(long ID, String deptCode,
        String deptDesc) throws CreateException {
        this.ID = ID;
        this.deptCode = deptCode;
        this.deptDesc = deptDesc;
        //get primary key
        String pk = (String)ctx.getPrimaryKey();
       }
  2. Hi,
       In your ejbCreate() method you return null value
    by using return null statement.This is the error
    You have to return your primary key which should be of type String.
  3. Hi,
         Sorry my answer is not appropriate for CMP.
    I think the error is your ejbCreate() method is declared with the return type String but for CMP bean it has to
    be declared as void.
    bye
    Rama
  4. the ejbCreate()has the datatype wrt your primaryKey.
  5. check your home interface and descriptor files once more.the code looks right.