Hi All,
follwoing is the code i used to get the session using
JPAKnowledgeService.newStatefulKnowledgeSession.
table for the mentioned classes are getting created, after that
JPAKnowledgeService.newStatefulKnowledgeSession() method throws following
exception....
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
env.set( EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager() );
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
-------------------------
persistence.xml
i copied only persistent unit part...
<persistence-unit name="org.drools.persistence.jpa">
<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>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<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" />
<property name="hibernate.connection.url"
value="jdbc:oracle:thin:@192.168.4.93:1521:POST" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.password"
value="voms_test"
/>
<property name="hibernate.connection.username"
value="voms_test"
/>
<property name="java.naming.factory.initial"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<!--
<property name="hibernate.format_sql"
value="true"/>
-->
</properties>
</persistence-unit>
but it throws exception
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:137)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:61)
* at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at com.sample.FirstTest.main(FirstTest.java:87)*
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.drools.persistence.jpa.impl.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:123)
... 3 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:132)
... 8 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:130)
... 8 more
Caused by: java.lang.NullPointerException
at
org.drools.persistence.session.JtaTransactionManager.rollback(JtaTransactionManager.java:178)
... 9 more