3 Replies Latest reply on Jul 11, 2005 11:34 AM by Adrian Brock

    TransactionRolledbackLocalException caused stateful session

    bbbear Newbie

      Hi,

      I'm using JBoss 4.0. I have a container-managed stateful session bean which will call a stateless session bean for some business logics. What I'm trying to do is to simulate a transaction rollback scenario to see my beans' behaviour.

      Something I don't understand, when I get a "TransactionRolledbackLocalException" in the stateless session bean, the caller bean (stateful) will do an activation when I re-invoke the method call. I've simulated this scenario few times, and each time, it gives the same result. From the log files, it didn't show the stateful session bean passivated. It only shows attempting to activate.

      ==========================================
      2005-07-04 12:09:13,520 DEBUG [org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager] Attempting to activate; ctx=org.jboss.ejb.StatefulSessionEnterpriseContext@a27e13
      2005-07-04 12:09:13,521 DEBUG [org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager] Reading session state from: /opt/jboss-4.0/server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser
      2005-07-04 12:09:13,532 DEBUG [org.jboss.ejb.plugins.AbstractInstanceCache] Activation failure
      javax.ejb.EJBException: Could not activate; failed to restore state; CausedByException is:
      /opt/jboss-4.0/server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser (No such file or directory)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:340)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.activate(StatefulSessionInstanceCache.java:99)
      at org.jboss.ejb.plugins.AbstractInstanceCache.doActivate(AbstractInstanceCache.java:412)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.doActivate(StatefulSessionInstanceCache.java:115)
      at org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java:109)
      at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:217)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:870)
      at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      java.io.FileNotFoundException: /opt/jboss-4.0/server/default/tmp/sessions/ModSession-eaq5cb77-9/eaq71zbn-14.ser (No such file or directory)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.(FileInputStream.java:106)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager$FISAction.run(StatefulSessionFilePersistenceManager.java:507)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager$FISAction.open(StatefulSessionFilePersistenceManager.java:516)
      at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:322)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.activate(StatefulSessionInstanceCache.java:99)
      at org.jboss.ejb.plugins.AbstractInstanceCache.doActivate(AbstractInstanceCache.java:412)
      at org.jboss.ejb.plugins.StatefulSessionInstanceCache.doActivate(StatefulSessionInstanceCache.java:115)
      at org.jboss.ejb.plugins.AbstractInstanceCache.get(AbstractInstanceCache.java:109)
      at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:217)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:870)
      at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)

      ==========================================

      Any idea why is this happened?

      My own thought is, do correct me if I'm wrong, the statelss session bean by default is using the same tx as the stateful session (for container-managed) bean. When "TransactionRolledbackLocalException" occurred, both beans is marked as "rollback only", hence caused the stateful session gone?

      My objective is not to cause the stateful session gone/passivated even there's a transaction rollback in the stateless session bean. One solution I could think of is to set the stateless session to Bean-managed and set "RequiresNew" tx attribute to the stateless session bean methods.

      Can I set tx attribute when it is a container-managed bean?

      Any better suggestion? Do advise.

      Thank you.

      Regards,
      bb