It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes About setSessionContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "About setSessionContext" Watch "About setSessionContext" New topic
Author

About setSessionContext

Li Xin
Ranch Hand

Joined: Feb 06, 2004
Posts: 37
Can some one explain why in setSessionContext method, I cannot get a reference to the EJB object? Why can't I just call getEJBObject() of session context?
Thanks.
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
The container hasn't finished creating the ejb object yet. When you ask your context for the ejb object, you are expecting to get a reference to an object that is completely ready for use.... but setSessionContext is one of the very methods that the container is invoking in order to get the ejb object ready to be used. Its just too early in the lifecycle.


Reid - SCJP2 (April 2002)
Dilli raj
Greenhorn

Joined: Jan 31, 2004
Posts: 24
The sequence is
Constructor, setSessionContext and then ejbCreate. The ejbObject is created only at the point of ejbCreate call. So setSesionContext is little too early for the getEJBObject() call.
Dilli


SCJP,SCWCD,SCBCD
pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
you can call getEJBhome() because it is already there but not
getEJBobject() because it is not yet formed totally ...i mean a session bean (stateful) is linked with its sessioncontext & ejbObject only after setSessionContext() and ejbCreate() are called,so a Session bean knows its EJBObject after ejbCreate().
hope this helps.


SCJP1.4,SCBCD
Failure is not when you fall down; its only when you fail to get up again.
Li Xin
Ranch Hand

Joined: Feb 06, 2004
Posts: 37
ok, got it! Thanks a lot!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About setSessionContext
 
Similar Threads
SessionContext called 2 and then 3 times
Cannot activate my Stateful Session Bean after it was passivated
StatefulSessionBean - regarding
Session Bean
getEJBObject in setSessionContext