Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

MDB tx rollback question

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I did the ejb mock test, there is sth I don't understand.

The test said the following statement regarding message-driven bean exception handling is false:

If a system exception is thrown by a method, the transaction is always rolled back by the container

The explanation is:
----------------------------------------------------
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 demaraction.
------------------------------------------------------

I agree that if the MDB in an unspecified transaction context, then there would be no rollback, but with BMT throw system exception, the container should rollback the tx, right?
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the whole idea with bean-managed transactions --- the container's hands are tied!
 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but it is the system exception, bean won't handle it and who will log the exception, rollback the exception and kill the bean ? it should be Container, isn't it ?
[ July 16, 2004: Message edited by: Jason Hunt ]
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jason Hunt:
but it is the system exception, bean won't handle it and who will log the exception, rollback the exception and kill the bean ? it should be Container, isn't it ?

[ July 16, 2004: Message edited by: Jason Hunt ]



In a BMT scenario, if the bean encounters a system exception, the current transaction will be NOT be rolled back(unless otherwise the bean handles the Exception and calls UserTransaction.rollback()). However, the container may choose to discard the instance or move it to the pool.

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Jason,
In EJB 2.1 Specs, Section 18.3.3, Table 19, Page 404, it says that when an MDB with Bean-Managed Transaction demarcation throws a System exception the container will do the following:

  • Log the exception or error.
  • Mark for rollback a transaction that has been started, but not yet completed, by the instance.
  • Discard instance.
  • Throw EJBException that wraps the original exception to resource adapter.



  • Best regards,
     
    Ranch Hand
    Posts: 210
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Like Nadeem said, its indeed in the spec. I think you are correct.
    For ejb2.0 spec see: 18.3.2 table 18.

    --EDIT--

    Is it possible to post the complete question with all the possible answers ?
    [ July 24, 2005: Message edited by: Koen Serneels ]
     
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    That's the whole idea with bean-managed transactions --- the container's hands are tied!


    Actually, no. BMT means that the developer demarcates the transaction boundaries. But if a system exception is thrown from a BMT bean method, the Container will step in an rollback the transaction. Remember, the Container is the boss!
     
    Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
    Low Tech Laboratory
    https://www.kickstarter.com/projects/paulwheaton/low-tech-0
    reply
      Bookmark Topic Watch Topic
    • New Topic