File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Session Beans CMT BMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Session Beans CMT BMT" Watch "Session Beans CMT BMT" New topic

Session Beans CMT BMT

AR Shah

Joined: Jan 08, 2006
Posts: 2
Hello Everyone,

just a quick question. On HFEJB pg 196 it tells us that:

(for STATEFUL Session Beans)

You CAN'T:
- force a trans to rollback (CMT beans)
- find out if trans already set to rollback (CMT beans)

But you CAN:
- get a trans ref and call meths on it (BMT beans)

I'm just wondering why you can access the BMT transaction but not the CMT transaction.

Many thanks
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
For a session bean, only the methods in the component interface are transactional, you need to mark them with a transaction attribute if you are using CMT. The home interface methods like create are non-transactional. Hence the container would run them in an Unspecified Transaction Context. The rule is that if a method runs in an Unspecified Transaction Context, then you cannot call context.setRollbackOnly() and context.getRollbackOnly() i.e. ask the container to rollback the transaction or check to see if it is rolled back. Doing so will throw an IllegalStateException. But if you are using BMT, you are free to get the UserTransaction reference and start your own transaction. This will be clearer after you read the transactions chapter.
AR Shah

Joined: Jan 08, 2006
Posts: 2
Thanks - that makes perfect sense!!
I agree. Here's the link:
subject: Session Beans CMT BMT
jQuery in Action, 3rd edition