Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Method Access Doubt for session bean

 
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.
 
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
 
    Bookmark Topic Watch Topic
  • New Topic