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!