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"?>
       <import resource="jbpm.jpdl.cfg.xml" />
       <import resource="jbpm.identity.cfg.xml" />
       <import resource="jbpm.jobexecutor.cfg.xml" />
       <repository-service />
       <repository-cache />
       <execution-service />
       <history-service />
       <management-service />
       <identity-service />
       <task-service />
       <!-- Here we needed to change the transaction interceptor -->
       <retry-interceptor />
       <environment-interceptor />
       <spring-transaction-interceptor current="true" />
       <!-- Added spring as read-context -->
       <script-manager default-expression-language="juel"
       read-contexts="execution, environment, process-engine, spring"
       <script-language name="juel"
       factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
       <authentication />
       <id-generator />
       <types resource="jbpm.variable.types.xml" />
       <address-resolver />
       <repository-session />
       <db-session />
       <message-session />
       <timer-session />
       <history-session />
       <session-properties resource="jbpm.mail.properties" />
       <!-- Need to set explicitly that we don't want jbpm to create sessions -->
       <hibernate-session />

      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?