permaculture playing cards
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Container and Rollback Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Container and Rollback" Watch "Container and Rollback" New topic

Container and Rollback

Rahul Goyanka

Joined: Aug 03, 2005
Posts: 7

Please comment on the truth ness of the following comments...

1. Container is not responsible for committing or rolling back transactions that have been initiated by the client.
2. The container is only responsible for rolling back a system exception for an message-driven bean with container-managed transaction demarcation and when the bean method runs in the context of a transaction started by the container. A transaction is not rolled backed by the container as a result of a system exception thrown when the transaction runs with an unspecified transaction context and also when a bean is declared with bean-managed transaction demarcation.

And what should be the correct answer for the following question...
What will the container do when a bean managed message driven bean throws a system exception? [Check all correct answers]
1. Log the system exception.
2. Mark the transaction for rollback.
3. The container will discard the message driven bean instance and will not invoke any business methods or container callbacks on the instance.
4. The container will commit the transaction unless the deployment descriptor specifies otherwise.
5. The client will receive a RemoteException.

As per the given answer... option 1, 2, and 3. I am confused as MDB is a BMT bean so option 2 should not be true.


Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Option 2 is correct. Remember, a transaction is scoped at method level. So, if a system exception is thrown, the container must ensure that the transaction is ended. (We are assuming that the exception is not handled.) This is done by marking for rollback a transaction that has been started, but not yet completed, by the instance.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
I agree. Here's the link:
subject: Container and Rollback
It's not a secret anymore!