Drools Flow Persistence issue

2 messages Options
Embed this post
Permalink
premkumar

Drools Flow Persistence issue

Reply Threaded More More options
Print post
Permalink
Hi,
     
      I am new to drools and drools flow and able successfully create an flow using Knowldebase.newStatefulKnowledgeSession();. The same i have tried configuring persistence service via JPAKnowledgeService using H2DB as specified in section 5.1.3 drools flow documentation https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html_single/index.html#d0e1496
getting an exception from SingleSessionCommandService during the user transaction context lookup since it return null ctx.lookup( "java:comp/UserTransaction".);

The project setup is Spring , Hibernate and Drools with H2db base. Also find the persistence.xml that i have used

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
  version="1.0"
  xsi:schemaLocation=
    "http://java.sun.com/xml/ns/persistence
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
     http://java.sun.com/xml/ns/persistence/orm
     http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/persistence">

  <persistence-unit  name="org.drools.persistence.jpa" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>processInstanceDS</jta-data-source>
                <class>org.drools.persistence.session.SessionInfo</class>
                <class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
                <class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
                <class>org.drools.persistence.processinstance.WorkItemInfo</class>
                <properties>
              <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
              <property name="hibernate.max_fetch_depth" value="3"/>
              <property name="hibernate.hbm2ddl.auto" value="update"/>
              <property name="hibernate.show_sql" value="true"/>
              <property name="hibernate.transaction.manager_lookup_class"
                        value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
    </properties>
  </persistence-unit>
</persistence>


 Please provide your inputs on the persistence usage and also share with me any sample project if you have done earlier.

thanks
Prem
Barry K

Re: Drools Flow Persistence issue

Reply Threaded More More options
Print post
Permalink
Not sure what your server is, but if it is Tomcat, you will need to add the following to you META-INF/context.xml


    <Transaction factory="org.objectweb.jotm.UserTransactionFactory"
       jotm.timeout="60"/>



Barry

premkumar wrote:
Hi,
     
      I am new to drools and drools flow and able successfully create an flow using Knowldebase.newStatefulKnowledgeSession();. The same i have tried configuring persistence service via JPAKnowledgeService using H2DB as specified in section 5.1.3 drools flow documentation https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html_single/index.html#d0e1496
getting an exception from SingleSessionCommandService during the user transaction context lookup since it return null ctx.lookup( "java:comp/UserTransaction".);

The project setup is Spring , Hibernate and Drools with H2db base. Also find the persistence.xml that i have used

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
  version="1.0"
  xsi:schemaLocation=
    "http://java.sun.com/xml/ns/persistence
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
     http://java.sun.com/xml/ns/persistence/orm
     http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/persistence">

  <persistence-unit  name="org.drools.persistence.jpa" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
                 <jta-data-source>processInstanceDS</jta-data-source>
                <class>org.drools.persistence.session.SessionInfo</class>
                <class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
                <class>org.drools.persistence.processinstance.ProcessInstanceEventInfo</class>
                <class>org.drools.persistence.processinstance.WorkItemInfo</class>
                <properties>
              <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
              <property name="hibernate.max_fetch_depth" value="3"/>
              <property name="hibernate.hbm2ddl.auto" value="update"/>
              <property name="hibernate.show_sql" value="true"/>
              <property name="hibernate.transaction.manager_lookup_class"
                        value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
    </properties>
  </persistence-unit>
</persistence>


 Please provide your inputs on the persistence usage and also share with me any sample project if you have done earlier.

thanks
Prem