5 Replies Latest reply on Mar 20, 2012 11:59 PM by lakshmi sampath

    Does RESOURCE_LOCAL work with JBPM

    lakshmi sampath Newbie

      Hi,

       

      How do I configure JBPM 5.1  to use resource_local. Is it even supported. JBPM always throws exception whenever I use RESOURCE_LOCAL in persistence.xml.

       

       

       

      thanks

      lakshmi.

        • 1. Re: Does RESOURCE_LOCAL work with JBPM
          Mauricio Salatino Master

          What exception? what are you doing?

          Cheers

          • 2. Re: Does RESOURCE_LOCAL work with JBPM
            lakshmi sampath Newbie

            Mauricio,  I am trying to create a statefull session, but the error always goes into checking for JTA UserTransaction inside SingleSessionCommandService.

             

            Here's the exception and below are my config files and java code. Hope its something simple you can point out!!! Thx

             

            --------------------------------------------------------------------------------------------------------------------------

             

            14:03:06,392 ERROR [SingleSessionCommandService] Could not commit session

            java.lang.NullPointerException

                    at org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:197)

                    at org.drools.persistence.jta.JtaTransactionManager.begin(JtaTransactionManager.java:150)

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

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

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

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

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

                    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)

                    at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)

                    at org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:122)

            -----------------------persistence.xml----------------------------------------------

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

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

                <non-jta-data-source>java:jbpmDS</non-jta-data-source>

               

                      <class>org.drools.persistence.info.SessionInfo</class>

                <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>

                <class>org.drools.persistence.info.WorkItemInfo</class>

                <class>org.jbpm.process.audit.ProcessInstanceLog</class>

                <class>org.jbpm.process.audit.NodeInstanceLog</class>

                <class>org.jbpm.process.audit.VariableInstanceLog</class>

               

                <properties>

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

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

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

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

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

                </properties>

              </persistence-unit>

            </persistence>

            ---------------Spring config  file----------------------------------

                      <jee:jndi-lookup id="processengine.dataSource" jndi-name="java:/jbpmDS"/>

                      <context:annotation-config/>

             

                      <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

                                <property name="entityManagerFactory" ref="entityManagerFactory" />

                      </bean>

                      <bean id="entityManagerFactory"

                                class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

                                <property name="persistenceUnitName" value="org.jbpm.engine.persistence.jpa" />

                                <property name="dataSource" ref="processengine.dataSource" />

                      </bean>

                      <bean id="processEngine" name="processEngine"

                                class="com.processengine.jbpm.impl.MyJBPMHandler">

                                <property name="emf" ref="entityManagerFactory" />

             

             

                      </bean>

            --------------End spring config file----------------------------------

            -------------------MyJBPMHandler Java class-----------------------------------------

            public class MyJBPMHandler{

            private javax.persistence.EntityManagerFactory emf;

            public EntityManagerFactory getEmf() {

                                return emf;

                      }

             

             

                      public void setEmf(EntityManagerFactory emf) {

                                this.emf = emf;

                      }

             

                      public void init(){

                                KnowledgeBase kbase  = KnowledgeBuilderFactory.newKnowledgeBuilder().newKnowledgeBase();

                                Environment env = KnowledgeBaseFactory.newEnvironment();

                                env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

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

                      }

            }

            ----------------------------------------------------------------------------

            • 3. Re: Does RESOURCE_LOCAL work with JBPM
              Maciej Swiderski Master

              Try adding your spring transaction manager into environment before you create stateful session. It should prevent intenal mechanism to look up transaction manager.

               

              HTH

              • 4. Re: Does RESOURCE_LOCAL work with JBPM
                lakshmi sampath Newbie

                Thanks Maciej,  That made it work!

                • 5. Re: Does RESOURCE_LOCAL work with JBPM
                  lakshmi sampath Newbie

                  I see this warning when jboss starts. Do you know how to make hibernate use thread context instead of JTA session context.

                   

                  WARN  [org.hibernate.impl.SessionFactoryImpl] JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()

                   

                   

                  thanks

                  lakshmi.