5 Replies Latest reply on Nov 13, 2009 4:46 AM by quanmie

    jbpm4 with spring PlatformTransactionManager problem

      Hi,all:
      jbpm4 with spring Errors:

      org.jbpm.api.JbpmException: No platformTransaction manager defined.
      org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:33)
      org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
      org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)


      applicationContext.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">


      <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">









      org.hibernate.dialect.OracleDialect
      true
      none





      classpath:jbpm.execution.hbm.xml
      classpath:jbpm.repository.hbm.xml
      classpath:jbpm.task.hbm.xml
      classpath:jbpm.history.hbm.xml
      classpath:jbpm.identity.hbm.xml









      <constructor-arg value="jbpm.cfg.xml" />


      <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
      <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
      <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
      <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>
      <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
      <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>



      jbpm.cfg.xml

      <?xml version="1.0" encoding="UTF-8"?>

      <jbpm-configuration>





      <process-engine-context>
      <repository-service />
      <repository-cache />
      <execution-service />
      <history-service />
      <management-service />
      <identity-service />
      <task-service />
      <command-service>
      <retry-interceptor />
      <environment-interceptor />
      <spring-transaction-interceptor current="true" />
      </command-service>


      <!-- Added spring as read-context -->
      <script-manager default-expression-language="juel"
      default-script-language="juel"
      read-contexts="execution, environment, process-engine, spring"
      write-context="">
      <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
      </script-manager>



      <id-generator />


      <address-resolver />

      <business-calendar>






      </business-calendar>

      <mail-template name='task-notification'>

      ${task.name}
      <![CDATA[Hi ${task.assignee},Task "${task.name}" has been assigned to you.${task.description}Sent by JBoss jBPM]]>
      </mail-template>

      <mail-template name='task-reminder'>

      ${task.name}
      <![CDATA[Hey ${task.assignee},Do not forget about task "${task.name}".${task.description}Sent by JBoss jBPM]]>
      </mail-template>
      </process-engine-context>
      <transaction-context>
      <repository-session />
      <db-session />

      <message-session />
      <timer-session />
      <history-session />
      <mail-session>
      <mail-server>
      <session-properties resource="jbpm.mail.properties" />
      </mail-server>
      </mail-session>

      <!-- Need to set explicitly that we don't want jbpm to create sessions -->
      <hibernate-session current="true" />

      </transaction-context>
      </jbpm-configuration>


      my jbpm.cfg.xml have errors?

        • 1. Re: jbpm4 with spring PlatformTransactionManager problem
          saraswati.santanu

          I dont see a transaction manager bean defined in your spring application context xml. Is it there? If it is not then you need to define one.

          • 2. Re: jbpm4 with spring PlatformTransactionManager problem

             

            "saraswati.santanu" wrote:
            I dont see a transaction manager bean defined in your spring application context xml. Is it there? If it is not then you need to define one.






            have a HibernateTransactionManager in applicationContext.xml

            • 3. Re: jbpm4 with spring PlatformTransactionManager problem

               

              "saraswati.santanu" wrote:
              I dont see a transaction manager bean defined in your spring application context xml. Is it there? If it is not then you need to define one.


              bean id="transactionManager"
              class="org.springframework.orm.hibernate3.HibernateTransactionManager">

              /bean


              have a HibernateTransactionManager in applicationContext.xml

              • 4. Re: jbpm4 with spring PlatformTransactionManager problem
                saraswati.santanu

                In that case I do not see a problem with your jbpm.cfg.xml file.

                It seems you are using jbpm4.0 version. There the execute method of EnvironmentInterceptor looks a bit different from the later versions. However things should work even with that.

                 public <T> T execute(Command<T> command) {
                 Environment environment;
                
                 if (command instanceof AbstractCommand) {
                 AbstractCommand abstractCommand = (AbstractCommand) command;
                 List<WireObject> txWireObjects = abstractCommand.getTxWireObjects();
                 environment = environmentFactory.openEnvironment(txWireObjects);
                
                 } else {
                 environment = environmentFactory.openEnvironment();
                 }
                
                 try {
                 return next.execute(command);
                
                 } finally {
                 environment.close();
                 }
                 }
                

                When you are using Jbpm with spring environmentFactory is an instance of SpringConfiguration. And you can see that some version of openEnvironment will be called in any case. Once openEnvironment is called SpringConfiguration it calls
                environment.setContext(new SpringContext(applicationContext));
                

                Then when it searches for the bean that implements PlatformTransactionManager it should get one from the applicationContext passed. So just by looking at the code and you configuration I can not find any problem which can lead to this exception.

                I have migrated to Jbpm4.2 and below is the configuration that I am using which works. Check if it helps

                Spring configuration - along with the beans below I have SessionFactory bean also configured, but not given here
                 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                 <property name="sessionFactory"><ref bean="sessionFactory"/></property>
                 <property name="nestedTransactionAllowed"><value>true</value></property>
                 </bean>
                
                 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
                 <property name="driverClass">
                 <value>oracle.jdbc.driver.OracleDriver</value>
                 </property>
                 <property name="jdbcUrl">
                 <value>jdbc:oracle:thin:@127.0.0.1:1521:xe</value>
                 </property>
                 <property name="properties">
                 <props>
                 <prop key="c3p0.acquire_increment">1</prop>
                 <prop key="c3p0.idle_test_period">100</prop>
                 <prop key="c3p0.max_size">100</prop>
                 <prop key="c3p0.max_statements">0</prop>
                 <prop key="c3p0.min_size">1</prop>
                 <prop key="user">santanu</prop>
                 <prop key="password">santanu</prop>
                 </props>
                 </property>
                 </bean>
                
                 <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
                 <constructor-arg value="jbpm/jbpm.cfg.xml" />
                 </bean>
                
                 <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
                 <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
                 <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
                 <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
                 <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
                 <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>
                


                And jbpm config
                <jbpm-configuration>
                 <process-engine-context>
                 <repository-service />
                 <repository-cache />
                 <execution-service />
                 <history-service />
                 <management-service />
                 <task-service />
                 <identity-service />
                 <command-service name="txRequiredCommandService">
                 <retry-interceptor />
                 <environment-interceptor />
                 <spring-transaction-interceptor/>
                 </command-service>
                
                 <hibernate-configuration>
                 <cfg resource="jbpm.hibernate.cfg.xml" />
                 </hibernate-configuration>
                
                 <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
                 <field name="commandService"><ref object="txRequiredCommandService" /></field>
                 </object>
                
                 <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
                
                 <deployer-manager>
                 <jpdl-deployer />
                 </deployer-manager>
                
                 <script-manager default-expression-language="juel"
                 default-script-language="juel"
                 read-contexts="execution, environment, process-engine"
                 write-context="">
                 <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
                 </script-manager>
                 <job-executor auto-start="false" />
                 <types resource="jbpm.variable.types.xml" />
                 </process-engine-context>
                
                 <transaction-context>
                 <repository-session/>
                 <db-session/>
                 <message-session/>
                 <timer-session/>
                 <history-session/>
                 <hibernate-session current="true"/>
                 </transaction-context>
                
                </jbpm-configuration>
                


                It will be a bit difficult for me to move back to jbpm4.0 and try your config. So cant really debug your problem.


                • 5. Re: jbpm4 with spring PlatformTransactionManager problem

                  thanks a lot . I changed jbpm4.0 to 4.2 and its works well.