Adding Transactions to Servlets with JOTM
Subject:   Transaction is flawed
Date:   2003-08-07 01:42:12
From:   jeff.mesnil
Response to: Transaction is flawed

The transaction manager is there to ensure that if a problem occurs in the commit() method, the transaction is then automatically rolled back.

Your code may also not worked with all JTA transaction managers: the commmit() and rollback() specifications states that "When this method completes, the thread becomes associated with no transaction".
If your call to commit() fails, the call to rollback() should then throw a IllegalStateException because your transaction has been disassociated from your thread in the commit() method.

It's really up to the commit() method to cleanly rollback the transaction because JTA implicitely states that you can't call *both* commit() and rollback() on the same transaction.