7 Replies Latest reply on Mar 27, 2014 5:52 AM by Maciej Swiderski

    Why TransactionManager can't find JTA Transaction?

    Andreas G. Novice

      My JBPM application runs in a virgo/tomcat server. I am using JBPM 6.0.1.

       

      Firstly I build the default RuntimeEnvironment:

           RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()

             .entityManagerFactory(entityManagerFactory)

             .userGroupCallback(userGroupCallback)

             .addAsset(resource, type)

             .get();

       

      When I want to create a singletonsession via RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment) the Exception

       

           java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException

            at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)

            at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:67)

            at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newKieSession(KnowledgeStoreServiceImpl.java:36)

            at org.kie.internal.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:121)

            at org.jbpm.runtime.manager.impl.factory.JPASessionFactory.newKieSession(JPASessionFactory.java:41)

            ...

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

            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)

            ... 102 more

           Caused by: javax.naming.NameNotFoundException: Name [java:comp/UserTransaction] is not bound in this Context. Unable to find [java:comp].

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

            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)

            ... 105 more

      is thrown.

       

      Like described in the documentation I placed the file jndi.properties in the root classpath of my application.

      The content of the file is "java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory".

       

      So the structure of my JBPM app is:

      JPBM-Workflows-App

      |-src

      |-META-INF

        |-persistence.xml

      |-jndi.properties

       

      I don't want to use a jta-datasource and therefore i define databse settings inside persistence.xml. The content of persistence.xml looks like:

      <?xml version="1.0" encoding="windows-1252" ?>

      <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

      version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">

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

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

      <properties>

            <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>

            <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=PM;"/>

           

            <property name="javax.persistence.jdbc.user" value="PMUser" />

            <property name="javax.persistence.jdbc.password" value="1234567" />

         

            <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>

            <property name="hibernate.max_fetch_depth" value="3"/>

            <property name="hibernate.hbm2ddl.auto" value="update" />

            <property name="hibernate.show_sql" value="false" />

            <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem to cause problems -->     

            <property name="hibernate.id.new_generator_mappings" value="false" />           

           

            <!-- Transaction Manager -->

            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform" />

            <property name="hibernate.jndi.class" value="bitronix.tm.jndi.BitronixInitialContextFactory"/>     

          </properties>          

      </persistence-unit>

      </persistence>

       

      Why jndi name java:comp/UserTransaction isn't rigistered? Who is responsible for registering that?