1 2 Previous Next 15 Replies Latest reply on May 5, 2015 7:16 PM by tujasiri

    What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?

    tujasiri

      @

      Greetings,

       

      I hope someone can answer this before I spend hours trying to figure it out!

       

      I'm using the PoolingDataSource Class to instantiate my transaction manager.  However, I'm not having much success with it. 

       

      MySQL is my default database.  I'm using:

       

       

      PoolingDataSource ds = new PoolingDataSource();

       

        ds.setUniqueName("java:jboss/datasources/jbpmDS");

        ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");

        ds.setMaxPoolSize(3);

        ds.setAllowLocalTransactions(true);

        ds.getDriverProperties().put("user", "root");

        ds.getDriverProperties().put("password", "rootpass");

        ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm6");

        ds.getDriverProperties().put("driverClassName", "com.mysql.Driver");


        ds.init();


      I get this when I run the code:


      bitronix.tm.resource.ResourceConfigurationException: cannot create JDBC datasource named java:jboss/datasources/jbpmDS

        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:92)

        at com.sample.ProcessTest.testProcess(ProcessTest.java:67)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

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

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

        at java.lang.reflect.Method.invoke(Method.java:606)

        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)

        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)

        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

        at org.junit.@runners.ParentRunner$1.schedule(ParentRunner.java:63)

        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: bitronix.tm.utils.PropertyException: no writeable property 'URL' in class 'bitronix.tm.resource.jdbc.lrc.LrcXADataSource'

        at bitronix.tm.utils.PropertyUtils.getSetter(PropertyUtils.java:318)

        at bitronix.tm.utils.PropertyUtils.setDirectProperty(PropertyUtils.java:217)

        at bitronix.tm.utils.PropertyUtils.setProperty(PropertyUtils.java:83)

        at bitronix.tm.resource.common.XAPool.createXAFactory(XAPool.java:304)

        at bitronix.tm.resource.common.XAPool.<init>(XAPool.java:63)

        at bitronix.tm.resource.jdbc.PoolingDataSource.buildXAPool(PoolingDataSource.java:101)

        at bitronix.tm.resource.jdbc.PoolingDataSource.init(PoolingDataSource.java:88)

        ... 26 more

       



      Please help.

      salaboy21

      krisverlaenen

      swiderski.maciej

        • 1. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
          pmm

          You should use the connection pool and transaction manager from JBoss AS, see https://docs.jboss.org/author/display/AS71/DataSource+configuration

          • 2. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
            tujasiri

            Thanks for the response Philippe.

            However, I don't see anything here that speaks to implementation of the transaction manager via Java.  Where is it exactly?

            • 3. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
              pmm

              If you use declarative transactions with EJBs there is no need to know where it is, "it just works". If you have a managed component somewhere (even a servlet is enough) you can get a javax.transaction.UserTransaction through resource injection via @Resource. If that is not an option for you you can look up the UserTransaction under "java:comp/UserTransaction". If that is also not an option for you you can lookup a javax.transaction.TransactionManager under "java:jboss/TransactionManager". Note the last option is not portable.

              • 4. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                tujasiri

                I keep encountering " unable to find a bound object at name 'java:jboss/UserTransaction".  I don't know what's missing.  Is there a way to bind that object? code: public class ProcessTest extends JbpmJUnitBaseTestCase {         @Test         public void testProcess() throws NamingException, NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException  {                 PoolingDataSource ds = new PoolingDataSource();                 ds.setUniqueName("java:jboss/datasources/jbpmDS");                 ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");                 ds.setMaxPoolSize(3);                 ds.setAllowLocalTransactions(true);                 ds.getDriverProperties().put("user", "root");                 ds.getDriverProperties().put("password", "pass");                 ds.getDriverProperties().put("url", "jdbc:mysql://localhost:3306/jbpm6");                 ds.getDriverProperties().put("driverClassName", "com.mysql.jdbc.Driver");                 ds.init();                 InitialContext initialContext = new InitialContext();                 Environment env = KnowledgeBaseFactory.newEnvironment();                 EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.persistence.unit" );                 BitronixTransactionManager tm = TransactionManagerServices.getTransactionManager();                 env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );                 env.set( EnvironmentName.TRANSACTION_MANAGER, tm); KieHelper kieHelper = new KieHelper();                 KieBase kbase = kieHelper.addResource(ResourceFactory                                         .newClassPathResource("briefverify_mod.bpmn2"))                                         .build();                 // create a new knowledge session that uses JPA to store the runtime state                 StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );                 AbstractAuditLogger auditLogger = AuditLoggerFactory.newJPAInstance(emf);                 ksession.addEventListener(auditLogger); KieRuntimeLogger logger = KieServices.Factory.get().getLoggers()                         .newThreadedFileLogger(ksession, "src/main/resources/mylogfile", 1000); try{                         ksession.getWorkItemManager().registerWorkItemHandler("Service Task",  new MyWorkItemHandler());                 }                 catch (Exception ex){                                 System.err.println("WorkitemHandler==>"+ex.toString());                 }                 System.out.println("before process instance start");                 System.out.println("Session ID ==>"+ksession.getId());                 ProcessInstance processInstance = ksession.startProcess("ServiceProcess");                 }                 catch(WorkflowRuntimeException e){                         System.err.println("processInstance Exception ==>"+e.toString());                 }                 System.out.println("process instance started");                 ksession.dispose(); logger.close();                 System.out.println("reached the end...");         } } Exception: javax.naming.NameNotFoundException: unable to find a bound object at name 'java:jboss/UserTransaction'         at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)         at javax.naming.InitialContext.lookup(InitialContext.java:411)         at com.sample.ProcessTest.testProcess(ProcessTest.java:112)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.lang.reflect.Method.invoke(Method.java:606)         at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)         at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)         at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)         at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)         at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)         at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)         at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)         at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)         at org.junit.runners.ParentRunner.run(ParentRunner.java:309)         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)         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) persistence.xml:

                    

                    java:jboss/datasources/jbpmDS    META-INF/Taskorm.xml    META-INF/JBPMorm.xml    META-INF/Executor-orm.xml    META-INF/Servicesorm.xml    META-INF/TaskAuditorm.xml     org.jbpm.services.task.impl.model.AttachmentImpl    org.jbpm.services.task.impl.model.ContentImpl    org.jbpm.services.task.impl.model.BooleanExpressionImpl    org.jbpm.services.task.impl.model.CommentImpl    org.jbpm.services.task.impl.model.DeadlineImpl    org.jbpm.services.task.impl.model.CommentImpl    org.jbpm.services.task.impl.model.DeadlineImpl    org.jbpm.services.task.impl.model.DelegationImpl    org.jbpm.services.task.impl.model.EscalationImpl    org.jbpm.services.task.impl.model.GroupImpl    org.jbpm.services.task.impl.model.I18NTextImpl    org.jbpm.services.task.impl.model.NotificationImpl    org.jbpm.services.task.impl.model.EmailNotificationImpl    org.jbpm.services.task.impl.model.EmailNotificationHeaderImpl    org.jbpm.services.task.impl.model.PeopleAssignmentsImpl    org.jbpm.services.task.impl.model.ReassignmentImpl    org.jbpm.services.task.impl.model.TaskImpl    org.jbpm.services.task.impl.model.TaskDefImpl    org.jbpm.services.task.impl.model.TaskDataImpl    org.jbpm.services.task.impl.model.UserImpl    org.jbpm.executor.entities.ErrorInfo    org.jbpm.executor.entities.RequestInfo   

                    org.jbpm.services.task.impl.model.BAMTaskSummaryImpl  

                    org.jbpm.services.task.audit.TaskEventImpl     org.drools.persistence.info.SessionInfo    org.jbpm.persistence.processinstance.ProcessInstanceInfo    org.drools.persistence.info.WorkItemInfo    org.jbpm.persistence.correlation.CorrelationKeyInfo org.jbpm.persistence.correlation.CorrelationPropertyInfo  

                    org.jbpm.runtime.manager.impl.jpa.ContextMappingInfo   

                    org.jbpm.process.audit.ProcessInstanceLog    org.jbpm.process.audit.NodeInstanceLog    org.jbpm.process.audit.VariableInstanceLog                                                                                                                   

                • 5. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                  pmm

                  The user transaction is under "java:comp/UserTransaction" not "java:jboss/UserTransaction". All of this doesn't work in unit tests because the unit tests don't run inside the container (unless you're using Arquilian).

                  • 6. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                    tujasiri

                    Okay Philippe, I'm now running as a Java application.  I've tried all the namespaces you listed.  By that, I mean I do the initial context lookup in the Java code:

                     

                         ut = (UserTransaction) new InitialContext().lookup( "java:jboss/TransactionManager" );  //This is the one shown in previous exceptions so i'm using it right now. I'm also using @Resource injection to implement the UserTransaction per your suggestion.

                     

                    And then I specify the jta.UserTransaction in my persistence.xml:

                     

                          <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

                          <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>

                          <property name="jta.UserTransaction" value="java:comp/UserTransaction" />

                       

                    This is my exception now:

                     

                         Exception in thread "main" javax.naming.NameNotFoundException: unable to find a bound object at name 'java:jboss/TransactionManager'

                           at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)

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

                           at com.sample.ProcessTest.testProcess(ProcessTest.java:172)

                           at com.sample.ProcessTest.main(ProcessTest.java:80)

                     

                     

                    I just don't understand why this fails.  Could you point me to a comprehensive setup of these components?  I've been unsuccessful at finding one. 


                    -TU

                    • 7. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                      pmm

                      Tajiri Ujasiri wrote:

                       

                             at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)

                      As I said, there's no need to patch your own custom transaction manager into JBoss AS, just use the default one.

                      Tajiri Ujasiri wrote:

                       

                      And then I specify the jta.UserTransaction in my persistence.xml:

                      None of this is needed, check out the https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide and the

                      • 8. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                        tujasiri

                        Thank you very much Sir.  I've abandoned the custom lookup class, removed the jta.UserTransaction property and strive to use the default TranactionManager namespace.  The system just does not find it.  I thought maybe somehow it wasn't configured, but I see the TM JNDI bindings in the Console:

                         

                        Screen Shot 2015-04-21 at 2.07.45 PM.png

                         

                        My code resembles any other example I've looked at:

                         

                         

                         

                        public class ProcessTest   {

                         

                          public static void main(String[] args) throws Throwable {

                         

                          ProcessTest pt = new ProcessTest();

                         

                         

                          try {

                          pt.testProcess();

                          } catch (Exception e) {

                               e.printStackTrace();

                               System.out.println(String.format("Cause==>%s\n",e.getCause().toString()));

                          }

                          }

                        @PersistenceContext

                        EntityManagerFactory emf;

                         

                        public void testProcess() throws NamingException, NotSupportedException, SystemException  {

                         

                          // create the entity manager factory and register it in the environment

                         

                          UserTransaction ut;

                          javax.transaction.TransactionManager tm;

                         

                          PoolingDataSource ds = new PoolingDataSource();

                        ds.setUniqueName("java:jboss/datasources/jbpmDS");

                          ds.setClassName("bitronix.tm.resource.jdbc.lrc.LrcXADataSource");

                         

                        ds.setMaxPoolSize(3);

                        ds.setAllowLocalTransactions(true);

                        ds.getDriverProperties().put("user", "root");

                        ds.getDriverProperties().put("password", "seven77");

                        ds.getDriverProperties().put("url", "jdbc:mysql://localhost:3306/jbpm6");

                        ds.getDriverProperties().put("driverClassName", "com.mysql.jdbc.Driver");

                         

                        try {

                          ds.init();

                          } catch (Exception e) {

                          e.printStackTrace();

                          }

                         

                          InitialContext initialContext = new InitialContext();

                         

                         

                          tm = TransactionManagerServices.getTransactionManager();

                          tm.begin();

                         

                         

                          Environment env = KnowledgeBaseFactory.newEnvironment();

                         

                          emf = Persistence.createEntityManagerFactory( "org.persistence.unit" );

                         

                          env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

                          env.set( EnvironmentName.TRANSACTION_MANAGER, tm);

                         

                          ut = (UserTransaction) new InitialContext().lookup( "java:comp/UserTransaction" );

                         

                          KieHelper kieHelper = new KieHelper();

                         

                            KieBase kbase = kieHelper.addResource(ResourceFactory

                          .newClassPathResource("briefverify_mod.bpmn2"))

                          .build();

                         

                          

                          // create a new knowledge session that uses JPA to store the runtime state

                          

                          StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );

                         

                         

                          AbstractAuditLogger auditLogger = AuditLoggerFactory.newJPAInstance(emf);

                         

                          ksession.addEventListener(auditLogger);

                         

                         

                          KieRuntimeLogger logger = KieServices.Factory.get().getLoggers()

                          .newThreadedFileLogger(ksession, "src/main/resources/mylogfile", 1000);

                         

                          //TestWorkItemHandler testHandler = getTestWorkItemHandler();

                         

                          try{

                                      ksession.getWorkItemManager().registerWorkItemHandler("Service Task"new MyWorkItemHandler());

                                    

                          }

                          catch (Exception ex){

                                         System.err.println("WorkitemHandler==>"+ex.toString());

                          }

                         

                          ProcessInstance processInstance = ksession.startProcess("ServiceProcess");

                         

                          ksession.dispose();

                          logger.close();

                         

                          }//end testProcess()

                         

                        }//end processTest()

                         

                        I stripped the seemingly extraneous properties from the persistence.xml:

                         

                        <properties>

                         

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

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

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

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

                        <!-- 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" />

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

                        <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

                        <property name="transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup"/>

                             

                        </properties>

                         

                         

                        And the exception trace:

                         

                        Cause==>java.lang.reflect.InvocationTargetException

                         

                        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 com.sample.ProcessTest.testProcess(ProcessTest.java:158)

                          at com.sample.ProcessTest.main(ProcessTest.java:68)

                        Caused by: java.lang.reflect.InvocationTargetException

                          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

                          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                          at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

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

                          ... 5 more

                        Caused by: org.hibernate.service.jndi.JndiException: unable to find transaction manager

                          at org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform.locateTransactionManager(JBossAppServerJtaPlatform.java:62)

                          at org.hibernate.service.jta.platform.internal.AbstractJtaPlatform.retrieveTransactionManager(AbstractJtaPlatform.java:104)

                          at org.hibernate.engine.transaction.internal.jta.JtaTransaction.getJoinStatus(JtaTransaction.java:274)

                          at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.attemptToRegisterJtaSync(TransactionCoordinatorImpl.java:222)

                          at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.pulse(TransactionCoordinatorImpl.java:269)

                          at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.getTransaction(TransactionCoordinatorImpl.java:188)

                          at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1209)

                          at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:178)

                          at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:89)

                          at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:179)

                          at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:174)

                          at org.drools.persistence.jpa.AbstractPersistenceContextManager.getApplicationScopedEntityManager(AbstractPersistenceContextManager.java:78)

                          at org.drools.persistence.jpa.JpaPersistenceContextManager.getApplicationScopedPersistenceContext(JpaPersistenceContextManager.java:61)

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

                          ... 10 more

                        Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:jboss/TransactionManager]

                          at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)

                          at org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform.locateTransactionManager(JBossAppServerJtaPlatform.java:55)

                          ... 23 more

                        Caused by: javax.naming.NameNotFoundException: unable to find a bound object at name 'java:jboss/TransactionManager'

                          at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:83)

                          at bitronix.tm.jndi.BitronixContext.lookup(BitronixContext.java:67)

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

                          at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)

                          ... 24 more

                         

                        As I debug, I see that every TM lookup fails.

                         

                        #STUMPED

                        • 9. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                          pmm

                          If I have to confess I don't know about Drools and how it integrates into JBoss AS. Can you try something like this and see if we get an exception about a missing transaction.

                           

                          public class ProcessTest {
                              public static void main(String[] args) throws Throwable {
                          
                                  ProcessTest pt = new ProcessTest();
                                  try {
                                      pt.testProcess();
                                  } catch (Exception e) {
                                      e.printStackTrace();
                                      System.out.println(String.format("Cause==>%s\n", e.getCause().toString()));
                                  }
                          
                              }
                          
                          
                              public void testProcess() throws NamingException, NotSupportedException, SystemException {
                          
                                  // create the entity manager factory and register it in the environment
                          
                                  InitialContext initialContext = new InitialContext();
                          
                                  Environment env = KnowledgeBaseFactory.newEnvironment();
                                  EntityManager em = (EntityManager) initialContext.lookup("java:comp/env/persistence/unit");
                                  EntityManagerFactory emf = em.getEntityManagerFactory();
                                  env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
                                  KieHelper kieHelper = new KieHelper();
                                  KieBase kbase = kieHelper.addResource(ResourceFactory
                                          .newClassPathResource("briefverify_mod.bpmn2"))
                                          .build();
                          
                                  // create a new knowledge session that uses JPA to store the runtime state
                          
                                  StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
                                  AbstractAuditLogger auditLogger = AuditLoggerFactory.newJPAInstance(emf);
                                  ksession.addEventListener(auditLogger);
                                  KieRuntimeLogger logger = KieServices.Factory.get().getLoggers()
                                          .newThreadedFileLogger(ksession, "src/main/resources/mylogfile", 1000);
                          
                                  // TestWorkItemHandler testHandler = getTestWorkItemHandler();
                          
                                  try {
                                      ksession.getWorkItemManager().registerWorkItemHandler("Service Task", new MyWorkItemHandler());
                                  }
                          
                                  catch (Exception ex) {
                                      System.err.println("WorkitemHandler==>" + ex.toString());
                                  }
                          
                                  ProcessInstance processInstance = ksession.startProcess("ServiceProcess");
                                  ksession.dispose();
                                  logger.close();
                          
                              }// end testProcess()
                          }
                          

                          You'll need to reference the persistence unit in the web.xml something like this

                           

                          <servlet>
                              <!-- drools servlet defintion -->
                              <persistence-context-ref>
                                  <persistence-context-ref-name>
                                      persistence/unit
                                  </persistence-context-ref-name>
                                  <persistence-unit-name>
                                      Drools <!-- Replace with name in persistence.xml -->
                                  </persistence-unit-name>
                              </persistence-context-ref>
                          </servlet>
                          
                          • 10. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                            tujasiri

                            Can I just add a web.xml to my project?

                            • 11. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                              pmm

                              I don't think that will work. How do you package and deploy your application (EAR, WAR, ...)?

                              • 12. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                                tujasiri

                                It did not.  I'm running this straight from my IDE--Eclipse.

                                 

                                I've since implemented a Spring config, and I'm getting "no active jta transaction found"  now.  I'll post the full stack trace shortly, as I do not have access to that machine right now.

                                • 13. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                                  pmm

                                  How are you running it from Eclipse? Using WTP and the JBoss Server Adapter (eg. your project is a Dynamic Web Project)? Or as a standalone Java Application?

                                  • 14. Re: What is the correct Transaction Manager to use in AS7 (and JBPM 6.2) in Java!?
                                    tujasiri

                                    I'm running it as a standalone Java Application.  I forgot to mention that my environment is a Mac.

                                    1 2 Previous Next