6 Replies Latest reply on Dec 14, 2013 10:46 PM by smarlow

    BAS014160: Wrong tx on thread

    azulitabijou

      I have a stateful bean that keeps throwing the below exception when I attempt to save the record to the database.  I have been searching, staring and reading for a few days, and haven't been able to pinpoint the issue.  Could someone be kind enough to point me in the right direction? I can post additional information if needed.  I tried removing @Stateful per a peer's suggestion and it gives me an XML error stating "This XML file does not appear to have any style information associated with it. The document tree is shown below." when I do so. Tools used: jbosseap 6.1 , deltaspike, hibernate

       

       

      JBWEB000065: HTTP Status 500 - java.lang.IllegalStateException: JBAS014160: Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null

       

       

      JBWEB000309: type JBWEB000066: Exception report

       

       

      JBWEB000068: message java.lang.IllegalStateException: JBAS014160: Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null

       

       

      JBWEB000069: description JBWEB000145: The server encountered an internal error that prevented it from fulfilling this request.

       

       

      JBWEB000070: exception

       

       

      javax.servlet.ServletException: java.lang.IllegalStateException: JBAS014160: Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null

        javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)

        org.monarchnc.filter.LoginFilter.doFilter(LoginFilter.java:41)

      JBWEB000071: root cause

       

       

      javax.faces.el.EvaluationException: java.lang.IllegalStateException: JBAS014160: Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null

        javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)

        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)

        org.apache.deltaspike.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:63)

        org.apache.deltaspike.jsf.impl.listener.action.DeltaSpikeActionListener.processAction(DeltaSpikeActionListener.java:51)

        javax.faces.component.UICommand.broadcast(UICommand.java:315)

        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)

        javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)

        com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

        com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

        org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeLifecycleWrapper.execute(DeltaSpikeLifecycleWrapper.java:75)

        javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

        org.monarchnc.filter.LoginFilter.doFilter(LoginFilter.java:41)

      JBWEB000071: root cause

       

       

      java.lang.IllegalStateException: JBAS014160: Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null

        org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:81)

        org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:252)

        org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:315)

        org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

        org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52)

        org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

        org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

        org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

        org.monarchnc.view.FireDrillBean$$$view295.completeDrill(Unknown Source)

        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        java.lang.reflect.Method.invoke(Method.java:616)

        org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)

        org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)

        org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)

        org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)

        org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:115)

        org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)

        org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

        org.monarchnc.view.FireDrillBean$Proxy$_$$_Weld$Proxy$.completeDrill(FireDrillBean$Proxy$_$$_Weld$Proxy$.java)

        org.monarchnc.view.FireDrillBean$Proxy$_$$_WeldClientProxy.completeDrill(FireDrillBean$Proxy$_$$_WeldClientProxy.java)

        sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        java.lang.reflect.Method.invoke(Method.java:616)

        org.apache.el.parser.AstValue.invoke(AstValue.java:258)

        org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)

        org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)

        org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)

        com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)

        javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)

        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101)

        org.apache.deltaspike.jsf.impl.config.view.ViewControllerActionListener.processAction(ViewControllerActionListener.java:63)

        org.apache.deltaspike.jsf.impl.listener.action.DeltaSpikeActionListener.processAction(DeltaSpikeActionListener.java:51)

        javax.faces.component.UICommand.broadcast(UICommand.java:315)

        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)

        javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)

        com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)

        com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

        org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeLifecycleWrapper.execute(DeltaSpikeLifecycleWrapper.java:75)

        javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

        org.monarchnc.filter.LoginFilter.doFilter(LoginFilter.java:41)

      JBWEB000072: note JBWEB000073: The full stack trace of the root cause is available in the JBoss Web/7.2.0.Final-redhat-1 logs.

       

       

      JBoss Web/7.2.0.Final-redhat-1

        • 1. Re: BAS014160: Wrong tx on thread
          nathandennis
          <exception-handler-factory>org.monarchnc.exception.jsf.DeltaSpikeExceptionHandlerFactory</exception-handler-factory>
          
          
          

          try removing the custom exception handling and definitely remove @Stateful from the class. post code ... the @Transactional from DS might also be causing trouble with your transaction. might need to move your transaction logic into another bean. ive had issues with annotating @transactional at the class level before.@ but i really believe that if you remove the above exception handling from the faces-config.xml and the @Stateful... you will find that you have two problems.. the @Stateful and a ".." or some other syntax error in a binding tag in aforementioned xml file.

          • 2. Re: BAS014160: Wrong tx on thread
            jaikiran

            Could you also post a bit more details about the flow of the application when this exception occurs?

            1 of 1 people found this helpful
            • 3. Re: BAS014160: Wrong tx on thread
              nathandennis

              lol jaikiran.jai_forums2005.yahoo.co.in i don't have extra sensory perception. I wrote that exception handler i told her to remove. i just dont work there anymore. I image that post was sort of hard to follow.

               

              azulitabijou post the backing bean... minus about 40 of those irrelevant fields... make sure you get the @Inject s with the entity manager.. and unless youve gone wild in the last 3 days,, the entity manager producer is operating in a request scope like mark struberg recommended and I polymorphized the it to get into the correct persistence context... show him that too. Transaction handling is using Deltaspike 0.5. Of course we expect this in a nicely formatted way with the appropriate styling from the advanced editor. by the way, look for your "..".. i still bet its in the xml somewhere.

              1 of 1 people found this helpful
              • 4. Re: BAS014160: Wrong tx on thread
                jaikiran

                nathan dennis wrote:

                 

                lol Jaikiran Pai i don't have extra sensory perception. I wrote that exception handler i told her to remove. i just dont work there anymore. I image that post was sort of hard to follow.

                 

                Thanks for that context, to me your previous post makes much more sense now

                • 5. Re: BAS014160: Wrong tx on thread
                  azulitabijou

                  I got it working thanks to Nathan.  It ended up being a sessionContext that got copied over from previous examples.  I removed stateful, added transactional and removed sessionContext.

                  • 6. Re: BAS014160: Wrong tx on thread
                    smarlow

                    This sounds like a slightly different issue but also has similar conditions as this WildFly 8 issueWFLY-2651 is the tracking jira for the linked issue.  I can't say for sure that WFLY-2651 is a valid bug report yet but it seems like it to me.  Perhaps the details in the jira may be interesting to others here.  It seems to be an ordering issue, where CMTTxInterceptor starts the JTA transaction and org.jboss.as.txn.deployment.TransactionRollbackSetupAction.checkTransactionStatus() ends the transaction before CMTTxInterceptor.endTransaction() gets to end the transaction. 

                     

                    In the CMTTxInterceptor.endTransaction() error message "Wrong tx on thread: expected TransactionImple < ac, BasicAction: 0:ffff7f000001:-22a0ec2d:52a78ea7:21ae status: ActionStatus.COMMITTED >, actual null", the "expected" transaction is the only that was started by CMTTxInterceptor and "actual" is the transaction that is returned by TransactionManager.getTransaction().

                     

                    The test case is attached to WFLY-2651 (see git link in first few lines of jira) and the initial forum post also includes some same code (async @WebServlet calling @Asynchronous bean).

                     

                    The workaround was changing the async webservlet to call a synchronous bean instead.  When that is done, the CMTTxInterceptor managed transaction ends before TransactionRollbackSetupAction.checkTransactionStatus() is called.

                     

                    Not sure if this helps with the issue reported here but if there is a separate bug, I would like to identify it.