0 Replies Latest reply on Jan 21, 2011 6:03 AM by Maciej Żerkowski

    jBPM3 with JPA2 (+Spring3, JBoss 4.2.3)

    Maciej Żerkowski Newbie

      Hello all!

       

      I have a question regarding configuration jBPM 3.2.6.SP1 with JPA2 (Hibernate implementation). I am new in jBPM and I would like to ask you how can I do that in a proper way? You can find my configuration bellow.

       

      What I would also like to know is – what in your opinion is the best approach to integrate jBPM with the web application (like in my case) - to integrate my persistent classes with the jBPM persistent classes and have one entity manager factory (hibernate session factory) or to use two data sources and synchronize transactions somehow.

       

      Can you give me some examples or links or maybe you have some tips or suggestions what is the best way (and how) to do this?

       

      I appreciate any help.

       

      Regards,

      Maciek

       

      my applicationContext.xml:

       

      <bean id="dataSource" class="org.springframework.

      jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/db" />
      </bean>

       

      <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
      </bean>
      </property>
      <property name="jpaProperties">
      <props>
      <prop key="database">...</prop>
      ...
      </props>
      </property>
      </bean>

       

      <bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory" />
      </bean>

       

      <tx:annotation-driven transaction-manager="transactionManager" />

       

      my persistence.xml:

       

      <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
      <class>com.myDVDStore...</class>
      ...
      </persistence-unit>

       

      my jbpm.cfg.xml:

       

      <jbpm-context>
      <service name="authentication"
      factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory"
      />
      <service name="logging"
      factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
      <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
      <service name="persistence">
      <factory>
      <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory"> // I probably need to extend this to put my service there?
      <field name="isTransactionEnabled">
      <false />
      </field>
      </bean>
      </factory>
      </service>
      <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
      <service name="scheduler"
      factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
      </jbpm-context>

       

       

      <bean id="dataSource" class="org.springframework.

      jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:comp/env/jdbc/db" />
      </bean>

       

      <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="persistenceXmlLocation"
      value="classpath:META-INF/persistence.xml" />
      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
      </bean>
      </property>
      <property name="jpaProperties">
      <props>
      <prop key="database">...</prop>
      ...
      </props>
      </property>
      </bean>

       

      <bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory" />
      </bean>

       

      my persistence.xml:

       

      <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
      <class>...</class>
      ...
      </persistence-unit>

       

      my jbpm.cfg.xml

       

      <jbpm-context>
      <service name="authentication"
      factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory"
      />
      <service name="logging"
      factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
      <service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" />
      <service name="persistence">
      <factory>
      <bean class="com.myapp.JpaDbPersistenceServiceFactory"> // I
      probably need to extend this to put my service there?
      <field name="isTransactionEnabled">
      <false />
      </field>
      </bean>
      </factory>
      </service>
      <service name="tx" factory="org.jbpm.tx.TxServiceFactory" />
      <service name="scheduler"
      factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
      </jbpm-context>

       

      <tx:annotation-driven transaction-manager="transactionManager" />