Hi,

These changes both make sense to me:

Converting RollbackException to
TransactionRolledbackException because JTA
says RollbackException be thrown, and EJB2.0
17.4.2.1 says TransactionRolledbackException
be thrown at the client.
Other than 17.4.2.1, EJB only mentions that
this be returned when the bean is using the
callers tx context, so I'm not really sure if
this exception must be thrown with REQUIRES_NEW.
After all, 17.4.2.1 says that this tells the
client that it is fruitless to continue the
transaction, but it was another transaction
that was rolled back. Maybe this transaction
should be thrown whenever the transaction of
the client has been marked for rollback.
Not sure. What do you think?

Catching Exception in the beforeCompletion
because JTA really doesn't define what
happens if this is thrown from the
Synchronization methods.

I've changed the TxCapsule to be more robust
in case of unexpected exceptions:
beforeCompletion() now catches Throwable, logs
them, and rolls back the transaction.
afterCompletion() now catches Throwable, logs
them, but otherwise ignores them.
Calls to the XAResource methods also now catch
Throwable, logs them, and rolls back the
transaction whenever possible.

Best Regards,

Ole Husgaard.


danch wrote:
> 
> Here's little patch (cvs diff -u) that fixed my immediate problems,
> although I didn't look to closely at the afterCompletions. I hope this
> at least saves you some time, or gives you a chuckle.
> 
> EntitySynchronizationInterceptor now catches Exception rather than
> RemoteException when calling commit (actually in beforeCompletion of
> the InstanceSynchronization inner class).
> 
> TxInterceptorCMT needed to catch the RollbackException and swizzle it
> into a TransactionRolledbackException (which subclasses RemoteException)
> so that it can be propogated to the client properly. NOTE: we probably
> need to consider what other exceptions need to be caught here, as
> Transaction.commit is declared as throwing a bunch!
> 
> thanks again!
> danch
> 
> Ole Husgaard wrote:
> 
> > Hi,
> >
> > Just had a quick look at this, and you are
> > absolutely right.
> >
> > Exceptions from beforeCompletion methods should
> > be caught and result in a rollback.
> > Exceptions from afterCompletion should be caught
> > and ignored (too late to rollback).
> >
> > And the XAResource calls have similar problems.
> >
> > I'm currently testing some other changes to
> > package org.jboss.tm.
> > I'll fix this too, and expect to commit in a day
> > or two.
> 
> Index: TxInterceptorCMT.java
> ===================================================================
> RCS file:
> /products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/TxInterceptorCMT.java,v
> retrieving revision 1.9
> diff -u -r1.9 TxInterceptorCMT.java
> --- TxInterceptorCMT.java    2000/12/07 15:44:25    1.9
> +++ TxInterceptorCMT.java    2001/01/23 06:09:04
> @@ -315,7 +315,14 @@
>                                   // a) everything goes well
>                                   // b) app. exception was thrown
>   //DEBUG Logger.debug("TxInterceptorCMT:before commit");
> -                                newTransaction.commit();
> +                                try  {
> +                                    newTransaction.commit();
> +                                }
> +                                catch
> (javax.transaction.RollbackException rb) {
> +                                    //the transaction took care of
> rolling herself back
> +                                    //the
> EntitySynchronizationInterceptor discarded the instance
> +                                    throw new
> TransactionRolledbackException(rb.getMessage());
> +                                }
>   //DEBUG Logger.debug("TxInterceptorCMT:after commit");
> 
>                               }
> @@ -415,7 +422,14 @@
>                               // This will happen if
>                               // a) everything goes well
>                               // b) app. exception was thrown
> -                            newTransaction.commit();
> +                            try  {
> +                                newTransaction.commit();
> +                            }
> +                            catch (javax.transaction.RollbackException
> rb) {
> +                                //the transaction took care of rolling
> herself back
> +                                //the EntitySynchronizationInterceptor
> discarded the instance
> +                                throw new
> TransactionRolledbackException(rb.getMessage());
> +                            }
>                           }
> 
>                           // set the old transaction back on the method
> invocation
> Index: EntitySynchronizationInterceptor.java
> ===================================================================
> RCS file:
> 
>/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java,v
> retrieving revision 1.30
> diff -u -r1.30 EntitySynchronizationInterceptor.java
> --- EntitySynchronizationInterceptor.java    2000/12/22 17:29:34    1.30
> +++ EntitySynchronizationInterceptor.java    2001/01/23 06:09:05
> @@ -346,7 +346,7 @@
>                    // Object has been removed -- ignore
>                 }
>             }
> -          catch (RemoteException e) {
> +          catch (Exception e) {
>                 Logger.exception(e);
> 
>                 // Store failed -> rollback!

Reply via email to