• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Method Access Doubt for session bean

Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic