5 Replies Latest reply on Mar 17, 2014 9:39 AM by buenavida

    JTA issue when starting a process from another thread

    garethed

      Hello,

       

      I have a queue of objects which contain all the information required to start a new process session.

      Using Spring's @Scheduled annotation I'm periodically calling a method to poll the queue and start new workflows running.

      The problem is because of the scheduling the method is called using another thread and the following error below occurs:

       

       

      {code}

      Caused by: java.lang.IllegalStateException: Unable to find transaction: java:comp/UserTransaction

                at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:124) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:69) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:303) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:117) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                ... 24 more

      Caused by: javax.naming.NameNotFoundException: java:comp/UserTransaction

                at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:121)

                at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:214)

                at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_10]

                at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:119) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                ... 27 more

       

      {code}

       

      I'm using jbpm 5.4 and JBoss 7.1

       

      I have read that using java:jboss/TransactionManager instead can resolve this issue but java:comp/UserTransaction is hard coded in the drools-persistence-jpa jar.

      Do I need to download the source and build another version of the jar?

      There must be a simple work around for this.

       

      Thanks in advance.

       

      Gareth.

        • 1. Re: JTA issue when starting a process from another thread
          ctkcin

          Hi,

           

          Getting same error. Did you get any solution?

           

          Thanks

          • 2. Re: JTA issue when starting a process from another thread
            swiderski.maciej

            first try with specifying the jndi name of transaction manager via system property:

            -Djbpm.tm.jndi.lookup=java:jboss/TransactionManager

            if that won't help you can look up transaction manager yourself and add it to Environment instance before creating ksession.

             

            HTH

            • 3. Re: JTA issue when starting a process from another thread
              ctkcin

              Hi Maciej,

               

              Got the solution. It has been fixed in latest version of JtaTransactionManager. I took class file and patched in drools-persistence-jpa-5.5.0.Final.jar.

               

              findUserTransaction() method is updated with fix.

               

              Thanks.

              • 4. Re: JTA issue when starting a process from another thread
                lauradp

                I had a similar issue and your solution (I tookJtaTransactionManager from version 6.0) works fine!

                 

                Thanks

                 

                Laura

                • 5. Re: JTA issue when starting a process from another thread
                  buenavida

                  I want to use JBPM in a tomcat server. The transaction type of the persistence is defined as RESOURCE_LOCAL.

                   

                  <persistence-unit name="org.jbpm.domain" transaction-type="RESOURCE_LOCAL">

                    <provider>org.hibernate.ejb.HibernatePersistence</provider>

                   

                  I am using jbpm 6.0.1 and I have got a similar error. Is this a problem of version 6.0.1? What I am doing wrong?

                   

                  Caused by: java.lang.IllegalStateException: Unable to find transaction: Name java:comp is not bound in this Context

                  at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:140)

                  at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:79)

                  at org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:320)

                  at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:112)

                  ... 103 more

                  Caused by: javax.naming.NameNotFoundException: Name java:comp is not bound in this Context

                  at org.apache.naming.NamingContext.lookup(NamingContext.java:804)

                  at org.apache.naming.NamingContext.lookup(NamingContext.java:168)

                  at javax.naming.InitialContext.lookup(InitialContext.java:392)

                  at org.drools.persistence.jta.JtaTransactionManager.findUserTransaction(JtaTransactionManager.java:132)