Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Transaction Query

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rajnish Bhasin
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks For yr Help Reid.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both transactions are rolledback due to the RemoteException/EJBException.
A good question and a good explanation!
 
No, tomorrow we rule the world! With this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic