aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transaction Query 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 "Transaction Query" Watch "Transaction Query" New topic
Author

Transaction Query

Rajnish Bhasin
Greenhorn

Joined: Mar 01, 2004
Posts: 29
Hi Everyone,
We are aware of the fact that- If a bean with CMT calls a method on a Bean with BMT, the transation would suspend becoz a BMT would not entertain any other transaction other than itself.
Lets say that the BMT method so called also has its own transaction....and that BMT method throws a SYSTEM Exception.
Now although the SPEC says that the Outer Transaction Started by the CMT has nothing to do with the one started by the BMT. But the point is that System Exceptions ask for Beans to be removed from the POOL and the Transaction to be rolled back.
Can anyone please tell me what will happen to the Transaction that was started by the CMT bean.
Thanks In Advance...


Best Regards,<br />Rajnish Bhasin.<br />SCJP<br />SCWCD<br />SCBCD
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
The relevant part of the spec is section 18.3.1, pg 377, table 16.

The container will throw RemoteException to a remote client, and EJBException to a local client.

So, let's call the CMT bean "beanC" and the BMT bean "beanB". beanC is calling beanB. When beanB throws a system exception, the container will throw either RemoteException or EJBException to beanC, depending on whether beanC is remote or local respectively.
If beanC is a remote client, it has no choice but to catch RemoteException because RemoteException is not a RuntimeException. Unless beanC chooses to mark its own transaction for rollback or throw a system exception of its own, beanC's transaction survives.
If beanC is a local client, it isn't forced to catch the EJBException because EJBException is a RuntimeException. Whether beanC's transaction will survive will depend on whether or not the beanC method allows a system exception (the one from beanB or something thrown within beanC) to be thrown to the container.


Reid - SCJP2 (April 2002)
Rajnish Bhasin
Greenhorn

Joined: Mar 01, 2004
Posts: 29
Thanks For yr Help Reid.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Both transactions are rolledback due to the RemoteException/EJBException.
A good question and a good explanation!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transaction Query