• 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

Stateless BMT SB - HFEJB contradict EJB spec?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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().
 
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic