Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes calling getEJBObject() in ejbCreate() of Stateless session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "calling getEJBObject() in ejbCreate() of Stateless session bean" Watch "calling getEJBObject() in ejbCreate() of Stateless session bean" New topic
Author

calling getEJBObject() in ejbCreate() of Stateless session bean

Kaarthik Sivashanmugam
Greenhorn

Joined: May 29, 2004
Posts: 26
Hi all,
I dont understand how we can get reference to EJBObject in ejbCreate method for a stateless session bean. From what I understand, the stateless session beans are created by the container (for this the bean constructor is called and then setSessionContext, ejbCreate methods are called) and kept in pool. Till this point the bean is tied only to the context and not to any EJBObject. If this is the case, how can we call getEJBObject in ejbCreate method ? Please respond if you know the answer.

Thanks in advance.

Karthik
Suman Sarker
Ranch Hand

Joined: May 06, 2004
Posts: 68
This topic was already discussed in this forum a few days back. You may want to checkthis out.


Suman A Sarker<br />SCJP, SCWCD, SCBCD<br /> <br />If You Can't Beat Them ... Join Them!
Kaarthik Sivashanmugam
Greenhorn

Joined: May 29, 2004
Posts: 26
Thanks for your reply, Suman. The link you sent however did not clear my doubt. The link for the discussion you sent concludes that because getEJBObject() is possible in ejbCreate(), EJBObject should have been created before that. I could infer that while reading HFEJB. But, I am interested to know when (and how) EJBObject creation happens for stateless session bean in relation to ejbCreate(). If I have to go with the OID in page 227 of HFEJB ejbCreate is possible in a "different/unrelated" time. So it can happen before or after the "client call" create(). If it happens before the "client call". EJBObject would not have been created during ejbCreate().

Also, another related question is, if every client creates a new EJBObject, does it mean that ejbCreate is called for every client? I assume it is not. As a result, if ejbCreate can access EJBObject, which client's EJBObject are we talking about ?
Vipin Mohan
Ranch Hand

Joined: Nov 15, 2003
Posts: 79
hi Karthik

I think you can get your answers here.
http://www.coderanch.com/t/157991/java-EJB-SCBCD/certification/Operations-allowed-methods-stateless-session

http://www.coderanch.com/t/158485/java-EJB-SCBCD/certification/beanness-stateless-session-bean

Thanks
Vipin
Kaarthik Sivashanmugam
Greenhorn

Joined: May 29, 2004
Posts: 26
Thanks Vipin. That was really helpful.
Girija Siva
Ranch Hand

Joined: Apr 23, 2004
Posts: 41
:-) So that's what the spec says karthik
Thanks Vipin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling getEJBObject() in ejbCreate() of Stateless session bean