Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method Access Doubt for session bean

 
gloxinia libidinous
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm going to appear for SCBCD exam in 2 weeks.

I came across one doubt while reading Head First EJB. In the book it is written like that

We can't get reference to current transaction (i.e. using getUserTransaction( )) from within the ejbCreate() and ejbRemove() method of BMT stateless session bean. (page 228)

While in spec. on page 90, I can see getUserTransaction method call is valid from the ejbCreate() and ejbRemove() methods.

Moreover, In spec they just mentioned about getUserTransaction() method only, not about other UserTransaction methods.

Can anyone help me out of this dilemma by specifying exactly which methods are valid from ejbCreate() and ejbRemove() methods?

Thanks in advance.
 
Ugender Rekulampally
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Gloxinia,
Stateless session bean's ejbCreate() is very ambiguous for sure. When container creates stateless session beans, container won't assign a valid EJBOject which represents a client but it assigns a dummy/fake EJBObject to the bean inorder to create the bean. So in this case you can access getUserTransaction method and UserTransaction methods but these are not valid as there is no real EJBObject is assigned to it.

So to avoid that confusion people think there can't be a UserTransaction access in ejbCreate method in Stateless Session Bean since there is no valid EJBObject available in that method .

please correct me if I am wrong here.

Thanks,
Ugender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic