[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2309) UserTransaction.commit() may throw a RollbackException(), in that case don't try to perform a UserTransaction.rollback()

Clint Popetz (JIRA) jira-events at lists.jboss.org
Tue Apr 15 16:23:04 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-2309?page=comments#action_12409012 ] 
            
Clint Popetz commented on JBSEAM-2309:
--------------------------------------

I think you're correct...I had made that patch rather early on in my understanding of Seam's tx mechanism.  Since RollbackInterceptor marks transactions as rollbackOnly without actually calling rollback(), we need the attempted commit() in Work in order to generate the exception that will cause the subsequent rollback() in the catch block, and then propogate the exception out to the rest of the world.

Thanks for committing the patch and catching my mistake.

> UserTransaction.commit() may throw a RollbackException(), in that case don't try to perform a UserTransaction.rollback()
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-2309
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2309
>             Project: Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.2.1.GA, 2.0.0.GA
>            Reporter: Denis Forveille
>         Assigned To: Norman Richards
>             Fix For: 2.0.2.CR1, 2.1.0.BETA1
>
>         Attachments: work-tx-rollback.diff
>
>
> In the org.jboss.seam.util.Work class, the call to userTransaction.commit() is surrounded by a try/catch(Exception). In the catch block, if an exception occurs during the commit, a UserTransaction.rollback() is attempted. This may fail as the UserTransaction.commit() may throw a RollbackException, and in that case the UserTransaction ihas already been rollbacked. So an attempt to perform a rollback on the UserTransaction result in an illegalstate exception. This happens to us when something goes wrong in the beforeCommit() methods and hibernate throws a StaleObjectStateException() 
> We use seam 1.2.1 + POJO + WebSphere v61.0..13
> The code could be something like this (Class Work.java):
>       try {
>          T result = work();
>          if (begin) {
>             log.debug("committing transaction");
>             userTransaction.commit();
>          }
>          return result;
>       } catch (Exception e) {
>          if (begin) {
>             log.debug("rolling back transaction");
>             if (userTransaction.getStatus() != STATUS_NO_TRANSACTION) {
>                userTransaction.rollback();
>             }
>          }
>          throw e;
> }
> Or the code could explicitely catch the RollbackException
> This could be applied at any place in the code when a UserTransaction.commit() is called.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list