0 Replies Latest reply on Oct 19, 2012 5:54 AM by Alberto Prieto

    jbpm 5.2 to jbpm 5.3

    Alberto Prieto Newbie

      Hi,

       

      I'm trying to migrate my app to jbpm 5.3 with spring. First my files:

       

       

      Beans:

       

           <jee:jndi-lookup id="JbpmDataSource" jndi-name="${jdbc.datasource.name}" />

       

          <drools:grid-node id="node1" />

       

                <drools:kbase id="kbase1" node="node1">

                          <drools:resources>

                                    <drools:resource type="CHANGE_SET" source="classpath:workflow/config/changeset.xml" />

                          </drools:resources>

                </drools:kbase>

       

             <bean id="entityManagerFactory" 

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

                          depends-on="JtaTransactionManager">

                          <property name="dataSource" ref="JbpmDataSource" />

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

                          <property name="persistenceXmlLocation" value="classpath:config/persistence/persistence.xml" />

              </bean>

       

                <bean id="htEm"

                          class="org.springframework.orm.jpa.support.SharedEntityManagerBean">

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

                </bean>

       

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

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

                          <!-- this must be true if using the SharedEntityManagerBean, and false

                                    otherwise -->

                          <property name="nestedTransactionAllowed" value="true" />

                </bean>

       

       

                <bean id="htTxMgr"

                          class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager">

                          <constructor-arg ref="jpaTxMgr" />

                </bean>

       

       

                <bean id="systemEventListener" class="org.drools.SystemEventListenerFactory"

                          factory-method="getSystemEventListener" />

       

       

                <bean id="taskServiceBean" class="org.jbpm.task.service.TaskService">

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

                </bean>

       

       

                <bean id="springTaskSessionFactory"

                          class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl"

                          init-method="initialize" depends-on="taskService">

                          <!-- if using the SharedEntityManagerBean, make sure to enable nested transactions -->

                          <property name="entityManager" ref="htEm" />

                          <property name="transactionManager" ref="htTxMgr" />

                          <property name="useJTA" value="false" />

                          <property name="taskService" ref="taskServiceBean" />

                </bean>

       

       

                <bean id="btmConfig" factory-method="getConfiguration"

                          class="bitronix.tm.TransactionManagerServices">

                          <property name="serverId" value="spring-btm" />

                </bean>

       

       

                <bean id="BitronixTransactionManager" factory-method="getTransactionManager"

                          class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"

                          destroy-method="shutdown" />

       

       

                <bean id="JtaTransactionManager"

                          class="org.springframework.transaction.jta.JtaTransactionManager">

                          <property name="transactionManager" ref="BitronixTransactionManager" />

                          <property name="userTransaction" ref="BitronixTransactionManager" />

                </bean>

      JbpmTaskServiceImpl.java

       

             @PersistenceUnit

                private EntityManagerFactory emf;

       

                 @Autowired

                private KnowledgeBase kbase;

       

                @Autowired

                private TaskSessionSpringFactoryImpl taskSessionFactory;

       

                private TaskServiceSession taskServiceSession;

       

              @PostConstruct

                private void initTaskServiceSession() {

       

       

                          Environment env = KnowledgeBaseFactory.newEnvironment();

                          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

                          env.set(EnvironmentName.TRANSACTION_MANAGER,

                                              TransactionManagerServices.getTransactionManager());

                          env.set(EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY,

                                              TransactionManagerServices

                                                                  .getTransactionSynchronizationRegistry());

                          env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());

                          env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,

                                              new ObjectMarshallingStrategy[] {

                                                                  new JPAPlaceholderResolverStrategy(env),

                                                                  new SerializablePlaceholderResolverStrategy(

                                                                                      ClassObjectMarshallingStrategyAcceptor.DEFAULT) });

       

       

                          this.taskServiceSession = this.taskSessionFactory

                                              .createTaskServiceSession();

                          // this.taskServiceSession = taskService.createSession();

       

       

                          StatefulKnowledgeSession ksession = JPAKnowledgeService

                                              .newStatefulKnowledgeSession(kbase, null, env);

       

       

                          CustomSyncWSHumanTaskHandler humanTaskHandler = new CustomSyncWSHumanTaskHandler(

                                              this, ksession);

       

       

                          humanTaskHandler.setLocal(true);

       

       

                          humanTaskHandler.connect();

       

       

                          ksession.getWorkItemManager().registerWorkItemHandler("Web Flow Task",

                                              humanTaskHandler);

                          ksession.getWorkItemManager().registerWorkItemHandler("Human Task",

                                              humanTaskHandler);

       

       

                          CustomWebServiceTaskHandler serviceHandler = new CustomWebServiceTaskHandler(

                                              ksession);

       

       

                          ksession.getWorkItemManager().registerWorkItemHandler(

                                              "Web Service Task", serviceHandler);

       

       

                          new JPAWorkingMemoryDbLogger(ksession);

                }

       

      When I try to start my server, I get javax.persistence.TransactionRequiredException: No local transaction to join. And when I debug, the ksession have a null WorkItemManager... don't know why.

       

      Thanks for your help.