0 Replies Latest reply on Aug 7, 2009 3:18 PM by Joe Schmoe

    jBPM 4 + Spring + JPA Working, but concerns...

    Joe Schmoe Newbie

      With the help of this post, I've managed to get jBPM working in our Spring evironment which uses JPA for persistence: http://www.inze.be/andries/2009/05/16/demo-on-spring-integration-with-jbpm4/

      jBPM uses the underlying hibernate session of course.

      I was wondering if anyone can see any potential problems with the way I've configured this. In order to get it working, I had to remove the current="true" attribute from the hibernate-session configuration. Is this going to cause problems with my transactions?

      Here is my jbpm.cfg.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <jbpm-configuration>
      
       <import resource="jbpm.jpdl.cfg.xml" />
       <import resource="jbpm.identity.cfg.xml" />
       <import resource="jbpm.jobexecutor.cfg.xml" />
      
       <process-engine-context>
       <repository-service />
       <repository-cache />
       <execution-service />
       <history-service />
       <management-service />
       <identity-service />
       <task-service />
      
       <!-- Here we needed to change the transaction interceptor -->
       <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>
      
       <authentication />
      
       <id-generator />
       <types resource="jbpm.variable.types.xml" />
      
       <address-resolver />
      
       </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 />
       </transaction-context>
      </jbpm-configuration>


      When using:
      <hibernate-session current="true" />


      I was getting the following exception:
      org.hibernate.HibernateException: No CurrentSessionContext configured!

      This is how I've configured spring to get the hibernate session factory:
      <bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory"/>


      Any thoughts? My main concern is that I may be breaking the jBPM transaction pattern of running inside the current transaction. If I remove current="true", won't jBPM start its own separate transaction?