This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Stateless session bean ejbCreate() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Stateless session bean ejbCreate()" Watch "Stateless session bean ejbCreate()" New topic

Stateless session bean ejbCreate()

Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

How is it that a stateless session bean can access it's EJBObject from it's ejbCreate() method? Judging by its lifecycle, the EJBObject is created when the client invokes create(), and the bean itself is created when ever the container feels like it.

Is it that the container allows it to access a temporary EJBObject or something?



Live life to an interface, not an implementation!
Makesh Kumar Ramakrishnan
Ranch Hand

Joined: Jan 07, 2006
Posts: 88
When the ejbCreate method is called, already newInstance and setSessionContext methods are executed.. So new object is created and its assigned with SessionContext. When you use SessionContext to get EJBObject in ejbCreate, you get the object which would be the same as returned by create method of Home object.
Please correct me if i am wrong


Makesh<br /> <br />SCJP | SCWCD | SCBCD | SCEA
I agree. Here's the link:
subject: Stateless session bean ejbCreate()
Similar Threads
confusion on ejbCreate
Getting EJBObject from ejbCreate() on stateless bean
Why can stateless ejbCreate() access EJBObject???
Stateless ejbCreate can access Component