• 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 ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Stateless BMT SB - HFEJB contradict EJB spec?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused about what is allowed in ejbCreate() and ejbRemove() for stateless BMT beans. According to the EJB spec (page 90) and some notes, you ARE allowed to get the user transaction from the SessionContext object (i.e. getUserTransaction()). But according to HFEjb (page 228) and some other notes, you ARE NOT allowed to get the user transaction.

Which is it? To me, it makes sense that you cannot get the user transaction. Creation of stateless SB's are not tied client calling create(). Only the container will invoke ejbCreate() and ejbRemove(), so you are not in a meaningful transaction context.

Anyone can clarify? Thanks!
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are absolutely right . You can only have transaction in business ,finder and methods other create remove etc .

EJB spec also says so.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Folks,

The specs says that we can get UserTransaction in ejbCreate() and ejbRemove() methods for stateless session bean with BMT.
I understand that getting an UserTransaction has nothing to do with the fact that when the ejbCreate()/ejbRemove() is invoked, there is no client tied to them.
Ranchers please correct me if I am wrong.

Nikhil, I guess you are referring to Entity beans.

Cheers,
Sandeep
[ June 12, 2006: Message edited by: Sandeep MP ]
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answering my own question.. Did some more research and there's a difference between calling getUserTransaction() and actually doing something with it (i.e. UserTransaction.setRollbackOnly())

BMT are allowed to call getUserTransaction() in ejbCreate() and ejbRemove() (CMT beans would get java.lang.IllegalStateException). But since ejbCreate/ejbRemove are run in an unspecified transaction context, you cannot do anything with the user transaction, like setRollbackOnly().
 
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic