EJB programming & troubleshooting: How to pass a JavaBean object to a EJB

  1. How to pass a JavaBean object to a EJB (4 messages)

    HI techies:

    I am working on Weblogic 6.1 and have developed a Mailing Stateless Session Bean.
    I have also done with some JavaBean to store the contents the user enters and appropriately process and send it to the EJB.I am facing a prb with the design now.Can anyone help me how to send the JavaBean to a EJB(Stateless Session Bean).

    Help me with some example to do the same from the client side i.e. a jsp/application etc .

    Looking to hear from you.


    Email:riteshr at suvistas dot com

  2. How to pass a JavaBean object to a EJB[ Go to top ]

    Just make sure your java bean implements the java.io.Serializable interface and you should be good to go. Every object that you use with EJB must implement the Serializable interface or have a parent object that implements the Serializable interface.

    Good luck,

  3. Kent is right, and JavaBeans should generally be serializable anyway, according to the JavaBeans stanadard conventions.
    I just wanted to note that not *all* objects you pass to an EJB must implement Serializable. Objects that are passed as fields of different objects do not have to implement Serializable - although they must be serializable at runtime. For more information see the Java Serialization spec. Also note the Remote objects can be passed to EJBs even if they are not serializable at all.

  4. How to pass a JavaBean object to a EJB[ Go to top ]


    Thanks for the same.
    I have developed the JavaBean using the java.io.Serializable interface.
    Well,how should i pass the javabean object to the EJB.

    It seems to me that the solution is to pass the JavaBean object to the Stateless session bean as a parm in your BUSINESS METHOD call.

    theBean = context.create();
    boolean result = theBean.sendMail(String smptHost,java.lang.Object);

    The java.lang.Object is nothing but a type casted object of type JavaBean.

    Would this work or can you suggest me a better alternative.


  5. How to pass a JavaBean object to a EJB[ Go to top ]

    If the object is Serializable, you can just pass it to your bean like any other normal paramter... what could be better than that?