.
I will fix it as soon as Mark fixes the trunk ;)
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Developer @
Thanks!
Can you elaborate the solution?
*From:* Esteban [via Drools - Java Rules Engine] [mailto:[hidden
email]<http://user/SendEmail.jtp?type=node&node=2602869&i=0>]
*Sent:* Tuesday, March 01, 2011 2:37 PM
*To:* Odelya Holiday
*Subject:* Re: Caused by: java.lang.NullPointerException at
org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
Unfortunately there is a "bug" (it is not really a bug but an omission in
the code) that hides the real exception going on. The piece of code giving
you troubles is (SingleSessionCommandService.java lines 119 - 138):
*try {*
* this.txm.begin();*
* *
* //this.appScopedEntityManager.joinTransaction();*
* registerRollbackSync();*
* jpm.getApplicationScopedPersistenceContext().persist(
this.sessionInfo );*
* this.txm.commit();*
* } catch ( Exception t1 ) {*
* try {*
* this.txm.rollback();*
* } catch ( Throwable t2 ) {*
* throw new RuntimeException( "Could not commit session or
rollback",*
* t2 );*
* }*
* throw new RuntimeException( "Could not commit session",*
* t1 );*
* }*
As you can see, when there is a problem in the body of the try-catch,
drools tries to rollback the session. If the rollback itself fails, you get
the exception "Could not commit session or rollback", but the original
exception (t1) is lost.
We already fixed a similar issue in SingleSessionCommandService#execute()
and created a rollbackTransaction() method that logs the first exception if
the session rollback fails.
So, the solution (not a solution but a hack to see what is really going
on) is to use the same rollbackTransaction() method in the catch part. If
you want to see the real exception, you will need to download
drools-persistence-jpa sources from
https://github.com/droolsjbpm/drools/tree/master/drools-persistence-jpa and
debug through the lines I mentioned. Or you can wait us to patch the code ;)
For the records, this is the bug previously reported:
https://issues.jboss.org/browse/JBRULES-2656. I will create a new one and
link them together.
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Developer @
http://www.plugtree.com
- Blog @
http://ilesteban.wordpress.com
On Tue, Mar 1, 2011 at 7:53 AM, odelyaholiday <[hidden
email]<http://user/SendEmail.jtp?type=node&node=2602731&i=0&by-user=t>>
wrote:
Hi!
I am working already for 3 days, trying to configure bitronix with spring
and drools.
I defined
1. persistence unit:
<persistence-unit name="org.drools.persistence.jpa"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/DS1</jta-data-source>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.autocommit"
value="false" />
<property name="hibernate.max_fetch_depth"
value="3"
/>
<property name="hibernate.show_sql"
value="true" />
<property
name="hibernate.current_session_context_class" value="jta" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.xa.client.OracleXADataSource" />
<property name="hibernate.jndi.class"
value="bitronix.tm.jndi.BitronixInitialContextFactory"/>
<property
name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
2. in my application context:
<!-- Bitronix Transaction Manager embedded configuration -->
<bean id="oracleDataSource"
class="bitronix.tm.resource.jdbc.PoolingDataSource"
init-method="init" destroy-method="close">
<property name="className"
value="oracle.jdbc.xa.client.OracleXADataSource" />
<property name="uniqueName" value="jdbc/DS1" />
<property name="maxPoolSize" value="5" />
<property name="allowLocalTransactions"
value="true" />
<property name="testQuery" value="SELECT 1 FROM
DUAL" />
<property name="driverProperties">
<props>
<prop key="user">myuser</prop>
<prop key="password">myuser</prop>
<prop key="URL">myurl</prop>
</props>
</property>
</bean>
<bean id="btmConfig" factory-method="getConfiguration"
class="bitronix.tm.TransactionManagerServices">
<property name="serverId" value="spring-btm" />
</bean>
<bean id="BitronixTransactionManager"
factory-method="getTransactionManager"
class="bitronix.tm.TransactionManagerServices"
depends-on="btmConfig"
destroy-method="shutdown" />
<bean id="JtaTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager"
ref="BitronixTransactionManager" />
<property name="userTransaction"
ref="BitronixTransactionManager" />
</bean>
<!-- end of Bitronix Transaction Manager embedded configuration -->
3. and in the code:
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
env.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager());
ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null,
env);
However in the last code I get:
Caused by: java.lang.IllegalStateException:
java.lang.reflect.InvocationTargetException
at
org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:130)
at
org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)
at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)
at
com.mycompany.util.BookWorkflowUtilities.createSession(BookWorkflowUtilities.java:83)
at
com.mycompany.util.BookWorkflowService.init(BookWorkflowService.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293)
at
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130)
... 29 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
... 40 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at
org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
... 45 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at
org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:184)
at
org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:131)
... 45 more
Caused by: java.lang.NullPointerException
at
org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-N...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
[hidden
email]<http://user/SendEmail.jtp?type=node&node=2602731&i=1&by-user=t>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[hidden
email]<http://user/SendEmail.jtp?type=node&node=2602731&i=2&by-user=t>
https://lists.jboss.org/mailman/listinfo/rules-users
------------------------------
*If you reply to this email, your message will be added to the discussion
below:*
http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-N...
------------------------------
View this message in context: RE: Caused by:
java.lang.NullPointerException at
org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionM...
Sent from the Drools - User mailing list
archive<http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Use...
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users