• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless BMT SB - HFEJB contradict EJB spec?

 
Darien Cheung
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!
 
Nikhil Goel
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.
 
Sandeep Prabhakar
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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic