Discussions

EJB design: Moving objects between client and EJB.

  1. Moving objects between client and EJB. (2 messages)

    I am facing problem for passing support objects to and fro between client and EJB Bean.
    1st:->
    --------------------
    pulic class entityEJB implements EntityBean{

    public Aobj aobj;
    public void getAobj(){

    System.out.println(aobj);//aobj is not null and is a proper aobj instance.
    return this.aobj;
    }
    }

    public class client{

    .....
    .....
    Aobj a =<remoteinterface>.getAobj();
    System.out.println(a);
    //a is null here.

    }

    Also:
    public class Aobj implements java.io.Serializable {

    **********************************************************
    2nd:->
    -------------------------
    pulic class entityEJB implements EntityBean{
    public int pk;
    ....;
    .....;
    public void ejbCreate(Sobj s){

    System.out.println(s);
    pk = s.id;
    ............;
    ........;
    }
    }

    public class client{
    Sobj sobj;
    .....
    sobj=new Sobj();
    sobj.pk=5;
    .......
    .....
       System.out.println(sobj);// sobj is proper Sobj instance.
    <remoteinterface> ri =<homeinterface>.create(sobj);
    //Error occurs here.

    }

    Also:
    public class Sobj implements java.io.Serializable {

    --------------------------------------
    For 2nd the error it gives is:

    javax.ejb.CreateException: A bean primary key field may not be null after ejbCreate has been called
            at weblogic.ejb.internal.StatefulEJBObject.postCreate(StatefulEJBObject.java:227)
            at storeBeanEOImpl.create(storeBeanEOImpl.java:60)
            at storeBeanHomeImpl.create(storeBeanHomeImpl.java:32)
            at storeBeanHomeImpl_WLSkel.invoke(storeBeanHomeImpl_WLSkel.java:98)
            at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerObjectAdapter.java, Compiled Code)
            at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicRequestHandler.java:69)
            at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:15)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

    ********************************

    Any help is appreciated.
    Thanks.
    kaustubh.
  2. First:
    ------
    < public void getAobj(); >
    The return can not be void! You should return the Aobj:
    public Aobj getAobj();

    Second:
    -------
    < public void ejbCreate(Sobj s)>

    The return must not be void and you should return the primary key so that home object can find the object.
    public integer ejbCreate(Sobj sj)




  3. return the object, not the void!!