0 Replies Latest reply: Apr 6, 2010 10:43 AM by dimitar dimitar RSS

EJB3.0 transaction not active Realy strange!!!

dimitar dimitar Newbie

SQL Error: 0, SQLState: null15:44:29,962 ERROR Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000001:c779:4bbb2b0e:505b status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: 7f000001:c779:4bbb2b0e:505b status: ActionStatus.ABORT_ONLY >)15:44:29,967 ERROR javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection15:44:29,970 ERROR PositionsManagementIntr::onMessage()::The exception type is: javax.ejb.EJBTransactionRolledbackException15:44:29,970 ERROR PositionsManagementIntr::onMessage()::The exception is:::org.hibernate.exception.GenericJDBCException: Cannot open connection15:44:29,970 ERROR javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection15:44:29,971 ERROR      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)15:44:29,971 ERROR      at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)15:44:29,971 ERROR      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)15:44:29,971 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,971 ERROR      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)15:44:29,971 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,971 ERROR      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)15:44:29,971 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,971 ERROR      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)15:44:29,971 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,971 ERROR      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)15:44:29,971 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,972 ERROR      at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)15:44:29,972 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,972 ERROR      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)15:44:29,972 ERROR      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)15:44:29,972 ERROR      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)15:44:29,972 ERROR      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)15:44:29,972 ERROR      at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)15:44:29,972 ERROR      at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)15:44:29,972 ERROR      at $Proxy731.method5(Unknown Source)

15:44:29,972 ERROR      at MyBean.method4(MyBean.java:337)15:44:29,972 ERROR      at MyBean.method3(MyBean.java:324)

15:44:29,972 ERROR      at MyBean.method2(MyBean.java:132)

15:44:29,972 ERROR      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

...............

 

at $Proxy851.onMessage(Unknown Source)15:44:29,978 ERROR      at ManagementBean.onMessage(PositionsQueueManager.java:59)

15:44:29,978 ERROR      at org.jboss.jms.client.container.ClientConsumer.callOnMessage(ClientConsumer.java:229)15:44:29,978 ERROR      at org.jboss.jms.client.container.ClientConsumer$ListenerRunner.run(ClientConsumer.java:1043)15:44:29,978 ERROR      at org.jboss.messaging.util.OrderedExecutorFactory$ChildExecutor.run(OrderedExecutorFactory.java:120)15:44:29,979 ERROR      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)15:44:29,979 ERROR      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)15:44:29,979 ERROR      at java.lang.Thread.run(Thread.java:619)

 

 

 

@Stateful
@CacheConfig(idleTimeoutSeconds = 3600)
public class ManagementBean implements IManagementLocal {

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void onMessage(final javax.jms.Message msg) { 
     method1(msg);
}

private void method1(msg) {
     for(...) {
          processBean.method2(...); //statless bean call



     }



}





}















@Statless



public class ProcessBean {







@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)



public void method2(...) {
 if(...) {
     method3(..);
} else { 
 try {
 method4(...);
 } catch(Exception e) {
     method3(...); 
     }
}
}

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void method3(...) {

     otherStatlesBean.method5(); //This is with the default trans atributte required
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void method4(...) {

}

}



 

I cannot understand WHY it is complaining with transaction not active

In method2 if method4 fails(it is executed in new separate tarnsaction) i catch the excepton and call method3 which calls statless bean method and there it complains that the transaction is not active, How can a just created new transaction  in the caller bean be not active???

I see that an EJBTransactionRolledbackException is thrown cause by my exception, which i try if i want to execute method3 so it roll back the whole transaction, NOT only the transaction in which method4 is executing???

 

I think i found it, my method3 is throwing runtime exeception which i think the container catch and rethrow as EJBTransactionRolledbackException, which causes the transaction to roll back. I did my exeception to be not RunTime and i will test.

The question is why it not rollback only the inner transaction, but and the outer transaction?