1 Reply Latest reply on Apr 15, 2008 6:06 AM by dhlbrk

    jBPM with Seam: Transaction problem

    cremersstijn

      I'm using jBPM in combination with Seam.
      I works fine...
      But aparently does jBPM not use the same transaction service as the other code.


      This is not good!, because if there goes something wrong, one transaction service will rollback, but the other won't, so i get bad data.


      the persistence.xml


      <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                   version="1.0">
                   
         <persistence-unit name="KvvDossiers">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:/KvvDossiersDatasource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
               <!-- property name="hibernate.hbm2ddl.auto" value="update"/ -->
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
               <property name="jboss.entity.manager.factory.jndi.name" value="java:/KvvDossiersEntityManagerFactory"/>
            </properties>
         </persistence-unit>
          
      </persistence>
      



      the jbpm.cfg.xml


      <jbpm-configuration>
      
        <jbpm-context>
          <service name="persistence">
             <factory>
                <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
                   <field name="isTransactionEnabled"><false/></field>
                </bean>
             </factory>
          </service>
          <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
          <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
          <service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
          <service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
          <service name="authentication" factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
        </jbpm-context>
      
      </jbpm-configuration>
      



      the hibernate.cfg.xml



      <hibernate-configuration>
        <session-factory>
      
          <property name="show_sql">true</property>
          <property name="connection.datasource">java:/KvvDossiersDatasource</property>
          <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
          <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
          <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
          <property name="hbm2ddl.auto">update</property>
          ...
        </session-factory>
      </hibernate-configuration>
      
      





        • 1. Re: jBPM with Seam: Transaction problem

          I think you need an XA datasource configured for both your seam application and for jBPM.


          Take a look here:


          http://docs.jboss.com/jbpm/v3/userguide/persistence.html



          A stateless session facade in front of jBPM is a good practice. The easiest way on how to bind the jbpm transaction to the container transaction is to make sure that the hibernate configuration used by jbpm refers to an xa-datasource. So jbpm will have its own hibernate session, there will only be 1 jdbc connection and 1 transaction.

          I actually could not get jBPM to work properly on SQL Server without   XA enabled.