• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

System exception in a BMT

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider the scenario:
1) A BMT session bean starts a transaction in a business method
2) Before the txn is committed, a system exception occurs
3) According to specs (page: 377, Table 16), container would mark the transaction for rollback and discard the bean.

Question: When will the transaction be rolled back ? Is it when the bean is discarded ?
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, when a bean throws a system exception to the container, the container kills the bean, does a rollback of the transaction, logs the exception and throws a RemoteException to remote clients and EJBException to local clients irrespective of whether it is CMT or BMT. This would typically happen immediately after the exception is thrown
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yes, when a bean throws a system exception to the container, the container kills the bean, does a rollback of the transaction, logs the exception and throws a RemoteException to remote clients and EJBException to local clients irrespective of whether it is CMT or BMT. This would typically happen immediately after the exception is thrown



Container does the rollback of transaction only if it has started the transaction. In case of BMT (according to specs 377, Table 16, page 378 Table 18), container only marks the transaction for rollback.

So my question once again: In case of BMT after a system exception is thrown When does the rollback of txn happen ?
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once the bean throw a system exception to container, the bean is possibly corrupt. The control is not going back to bean now. The container will rollback the transaction and throw a RemoteException or EJBException (local) to client (if there is a client). The bean will be killed.
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how I understand it. In case of BMT, rollback will happen only if ut.rollback() is called. As Devender said, once a System Exception is thrown to the container, control is not going back to the bean. So ut.commit() or ut.rollback() can never be executed in that transaction context. That means what happens to the transaction? Can you say it is NOT committed (because ut.commit() is not executed). A non-commited transaction or in other words, an abandoned transaction is as good as one that's rolled back right?
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abandoned transaction as good as committed transaction


How can it be ? Committed transaction - releases resources / locks etc.
Abandoned transaction - the txn is live holding on to resources / locks.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is quite simple what happens, regardless of whether it is a CMT or BMT session bean. Once a system exception is thrown by a bean method, the container will mark the transaction for rollback. Typically, the container will delegate to a transaction manager the job of actually doing the rollback of the transaction. Therefore, the transaction will be properly completed.
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That clarifies. Thanks Roger.
 
pie. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic