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?
SCJP, SCWCD, SCBCD, SCDJWS, OCA9i,<br />IBM Certified WAS5.0 Admin<br />IBM Certified Solution Developer - WebSphere Studio 5.0<br />IBM Certified Solution Developer - XML and related Technologies
Nathaniel Stoddard
Ranch Hand
Joined: May 29, 2003
Posts: 1258
posted
0
That's the whole idea with bean-managed transactions --- the container's hands are tied!
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 ]
Keerthi P
Ranch Hand
Joined: Aug 19, 2003
Posts: 203
posted
0
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.
Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Nadeem Awad
Ranch Hand
Joined: Jan 09, 2005
Posts: 74
posted
0
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,
Share Knowledge to gain it.<br /> <br />SCJP 1.2, SCDJWS 1.4, SCWCD 1.4, SCBCD 1.3, ICAD
Jim Janssens
Ranch Hand
Joined: Sep 24, 2004
Posts: 210
posted
0
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 ]
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
posted
0
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!
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.