[rules-users] Problem in getting session from JPAKnowledgeService.newStatefulKnowledgeSession();

Bennet Joseph josedrools at gmail.com
Thu Nov 25 11:30:32 EST 2010


HI

can you please elaborate on this please, i didn't understand.

in the previous example no where i used datasource to connect.

thanks,

jose



2010/11/25 tangrui.cn at gmail.com <tangrui.cn at gmail.com>

> If you use the JTA transaction manager, you should use Oracle's XA data
> source rather than the thin client.
>
> And Oracle needs specific permissions to run under JTA environment. Please
> check this page.
>
>
> http://docs.codehaus.org/display/BTM/FAQ#FAQ-WhyisOraclethrowingaXAExceptionduringinitializationofmydatasource%3F
>
> 2010/11/25 Bennet Joseph <josedrools at gmail.com>
>
>>  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
>>
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> 唐睿
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101125/2dc34407/attachment.html 


More information about the rules-users mailing list