Ole Husgaard wrote:

> 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?
I thought about that also, in fact I was throwing RemoteException at 
first. My reasoning was that since the spec says to throw 
RemoteException in other cases, and TransactionRolledBackException is a 
RemoteException, at worst it would do no harm.

> 
> 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.
>> 


Reply via email to