2 Replies Latest reply on Feb 19, 2013 8:33 AM by gonzalad

    jBPM 5.4 : LocalTaskService transaction handling within CMT transaction

    gonzalad

      Hello,

       

      I'm using LocalTaskService inside an EJB CMT.

       

      Problem is, whenever TaskService generates an error, it tries to rollback the transaction calling ut.rollback() instead of ut.setRollbackOnly().

       

      So, the original exception is swallowed and instead I get

       

      Caused by: java.lang.IllegalStateException: JBAS014160: Tx erroné pour cette chaîne : TransactionImple < ac, BasicAction: 0:ffff0affce14:-23020732:512359da:43 status: ActionStatus.ABORTED > attendu, mais avons null
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:80) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:230) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:302) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:188) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:42) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:181) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
        at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.3.Final.jar:7.1.3.Final]
        at com.natixis.odeon.process.SampleProcessService$$$view9.forward(Unknown Source) [classes:]
      
      

       

       

      I think there's an error in org.jbpm.task.service.TaskServiceSession, lien 462, takeOverTransaction should be false when we're running inside an EJB CMT.

       

      } catch (RuntimeException re) {
      
          // We may not be the tx owner -- but something has gone wrong.
          // ..which is why we make ourselves owner, and roll the tx back. 
          boolean takeOverTransaction = true;
          tpm.rollBackTransaction(takeOverTransaction);
      
      
          doOperationInTransaction(new TransactedOperation() {
              public void doOperation() {
                  task.getTaskData().setStatus(Status.Error);
              }
          });
      
      
          throw re;
      } 
      

       

      I'll update this thread whenever I'll have more info.

       

      Can someone confirm this is a bug in jBPM ?

       

      Thanks

        • 1. Re: jBPM 5.4 : LocalTaskService transaction handling with CMT transaction
          gonzalad

          I changed TaskServiceSession implementation with the one attached.

           

          The change is localized in the catch(Runtime re) showed in the previous post.

           

          I've change it like this :

           

           

          } catch (RuntimeException re) {
          
            tpm.rollBackTransaction(transactionOwner);
          
          
            if (transactionOwner) {
                doOperationInTransaction(new TransactedOperation() {
                    public void doOperation() {
                        task.getTaskData().setStatus(Status.Error);
                    }
                });
            }
          
          
            throw re;
          } 
          
          

           

          Explanation:

          • tpm.rollBackTransaction(transactionOwner) : this calls ut.setRollbackOnly(true) in the context of CMT transaction.
          • if (transactionOwner) : updating task SGBD table cannot be done in a CMT transaction when rollback has been requested (we would need to start a new transaction for this).

          With this change, I can now see the real exception :

          Caused by: org.jbpm.task.service.PermissionDeniedException: User '[User:'admin']' does not have permissions to execution operation 'Forward' on task id 34
          



          • 2. Re: jBPM 5.4 : LocalTaskService transaction handling with CMT transaction
            gonzalad