I have a stateful session bean that will deadlock relatively easily. I'd like very much to be able to detect deadlock situations and restart offending transactions.
My beans has CMT, and org.jboss.ejb.plugins.TxInterceptorCMT successfully detects deadlocks, throws an ApplicationDeadlockException, and re-tries the transaction. Unfortunately, org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor is higher in the interceptor stack, and has already caught the ApplicationDeadlockException, and, as it is a subclass of java.rmi.RemoteException, has discarded the offending session bean instance. Thus when TxInterceptorCMT re-tries the transaction, the offending session bean instance is no longer available, and a java.rmi.NoSuchObjectException is thrown and propagated to the client.
The result is my client gets a NoSuchObjectException (with no chained exceptions) and has no way of determining whether this was due to a deadlock (in which case it can automatically create a new session bean instance, and re-try the transaction) or some other exceptional error.
Is there any way to "save" a stateful session bean instance from being discarded when a deadlock is detected by JBoss? If not, is there any way to prevent TxInterceptorCMT from re-trying transactions that have deadlocked, without recompiling TxInterceptorCMT or setting TxInterceptorCMT.MAX_RETRIES from custom Java code? Should I use BMT instead?
I'm using JBoss 3.2.3. Any help will be much appreciated.