Moving objects between client and EJB.


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.
    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();
    //a is null here.


    public class Aobj implements {

    pulic class entityEJB implements EntityBean{
    public int pk;
    public void ejbCreate(Sobj s){

    pk =;

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


    public class Sobj implements {

    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(
            at storeBeanEOImpl.create(
            at storeBeanHomeImpl.create(
            at storeBeanHomeImpl_WLSkel.invoke(
            at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(, Compiled Code)
            at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(
            at weblogic.rmi.internal.BasicExecuteRequest.execute(
            at, Compiled Code)


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

    < 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!!