IllegalStateException When OC4J calls setRollbackOnly() Method With No Transaction Context (Doc ID 845593.1)

Last updated on MARCH 08, 2017

Applies to:

Oracle Containers for J2EE - Version: 10.1.3.3.0 and later   [Release: AS10gR3 and later ]
Information in this document applies to any platform.

Symptoms

A Stateless Session bean (EJB 3.0 ) has a  method marked with the following NEVER transaction attribute:

@TransactionAttribute(TransactionAttributeType.NEVER)

public void throwMyException () throws RemoteException, TestBeanException{
..
if( x == 2) {
..
   throw new TestBeanException("throwMyException method ");
}
}


This method is throwing  the TestBeanException  exception defined with the rollback attribute set to true :

@ApplicationException(rollback = true)
public class TestBeanException extends Exception {
public TestBeanException(String pMessage) {
super(pMessage);
}
}


Because the  throwMyException()  method is marked with NEVER transaction attribute,
the expected behavior  is  that  no transaction rollback is done.

The issue is that OC4J  is trying to rollback a transaction (call to setRollbackOnly() method );  as a result,  this exception occurs  :

java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated
with a transaction
at
com.evermind.server.ejb.EJBTransactionManager.setContainerRollbackOnly(EJBTransactionManager.java:23
2)
at
com.evermind.server.ejb.interceptor.system.AbstractTxInterceptor.convertAndHandleMethodException(Abs
tractTxInterceptor.java:68)
at
com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.
java:55)





.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms