For the records: I have created <meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://issues.jboss.org/browse/JBRULES-2913">https://issues.jboss.org/browse/JBRULES-2913</a>. I will fix it as soon as Mark fixes the trunk ;)<div>

<br></div><div>Best Regards,<br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>


<br><br><div class="gmail_quote">2011/3/1 odelyaholiday <span dir="ltr">&lt;<a href="mailto:odelyay@sintecmedia.com">odelyay@sintecmedia.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


                
                <div><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thanks!</span></p><p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Can you elaborate the solution?</span></p><p class="MsoNormal">

<span style="font-size:11.0pt;color:#1F497D"> </span></p><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt">From:</span></b><span style="font-size:10.0pt"> Esteban [via Drools - Java Rules Engine] [mailto:<a href="http://user/SendEmail.jtp?type=node&amp;node=2602869&amp;i=0" rel="nofollow" target="_blank">[hidden email]</a>] <br>

<b>Sent:</b> Tuesday, March 01, 2011 2:37 PM<br><b>To:</b> Odelya Holiday<br><b>Subject:</b> Re: Caused by: java.lang.NullPointerException at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)</span></p>

</div><div class="im"><p class="MsoNormal"> </p><p class="MsoNormal">Unfortunately there is a &quot;bug&quot; (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):</p>

<div><p class="MsoNormal"> </p></div><div><div><p class="MsoNormal">    <i><span style="font-family:&quot;Courier New&quot;">try {</span></i></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            this.txm.begin();</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;"> </span></i></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            //this.appScopedEntityManager.joinTransaction();</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            registerRollbackSync();</span></i></p></div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            jpm.getApplicationScopedPersistenceContext().persist( this.sessionInfo );</span></i></p>

</div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            this.txm.commit();</span></i></p></div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal">

<i><span style="font-family:&quot;Courier New&quot;">        } catch ( Exception <b>t1</b> ) {</span></i></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            try {</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">                <b>this.txm.rollback();</b></span></i></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            } catch ( Throwable t2 ) {</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">               <b> throw new RuntimeException( &quot;Could not commit session or rollback&quot;,</b></span></i></p></div><div><p class="MsoNormal">

<b><i><span style="font-family:&quot;Courier New&quot;">                                            t2 );</span></i></b></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            }</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">            throw new RuntimeException( &quot;Could not commit session&quot;,</span></i></p></div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">                                        t1 );</span></i></p>

</div><div><p class="MsoNormal"><i><span style="font-family:&quot;Courier New&quot;">        }</span></i></p></div></div><div><p class="MsoNormal"> </p></div><div><p class="MsoNormal">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 &quot;Could not commit session or rollback&quot;, but the original exception (t1) is lost.</p>

</div><div><p class="MsoNormal">We already fixed a similar issue in SingleSessionCommandService#execute() and created a rollbackTransaction() method that logs the first exception if the session rollback fails. </p></div>
<div>
<p class="MsoNormal">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 <a href="https://github.com/droolsjbpm/drools/tree/master/drools-persistence-jpa" rel="nofollow" link="external" target="_blank">https://github.com/droolsjbpm/drools/tree/master/drools-persistence-jpa</a> and debug through the lines I mentioned. Or you can wait us to patch the code ;)</p>

</div><div><p class="MsoNormal">For the records, this is the bug previously reported: <a href="https://issues.jboss.org/browse/JBRULES-2656" rel="nofollow" link="external" target="_blank">https://issues.jboss.org/browse/JBRULES-2656</a>. I will create a new one and link them together. </p>

</div><div><p class="MsoNormal"> </p></div></div><div><div class="im"><p class="MsoNormal" style="margin-bottom:12.0pt">Best Regards,<br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>

- Developer @ <a href="http://www.plugtree.com" rel="nofollow" link="external" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" rel="nofollow" link="external" target="_blank">http://ilesteban.wordpress.com</a><br>

<br></p></div><div><div><div></div><div class="h5"><p class="MsoNormal">On Tue, Mar 1, 2011 at 7:53 AM, odelyaholiday &lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=2602731&amp;i=0&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt; wrote:</p>

</div></div><p class="MsoNormal"></p><div><div></div><div class="h5">Hi!<br><br>I am working already for 3 days, trying to configure bitronix with spring<br>and drools.<br><br>I defined<br><br>1. persistence unit:<br><br>

&lt;persistence-unit name=&quot;org.drools.persistence.jpa&quot; transaction-type=&quot;JTA&quot;&gt;<br>               &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<br>               &lt;jta-data-source&gt;jdbc/DS1&lt;/jta-data-source&gt;<br>

               &lt;class&gt;org.drools.persistence.info.SessionInfo&lt;/class&gt;<br><br>&lt;class&gt;org.jbpm.persistence.processinstance.ProcessInstanceInfo&lt;/class&gt;<br>        &lt;class&gt;org.drools.persistence.info.WorkItemInfo&lt;/class&gt;<br>

               &lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;<br>               &lt;properties&gt;<br>                       &lt;property name=&quot;hibernate.dialect&quot;<br>value=&quot;org.hibernate.dialect.Oracle10gDialect&quot; /&gt;<br>

                       &lt;property name=&quot;hibernate.connection.autocommit&quot; value=&quot;false&quot; /&gt;<br>                       &lt;property name=&quot;hibernate.max_fetch_depth&quot; value=&quot;3&quot; /&gt;<br>

                       &lt;property name=&quot;hibernate.show_sql&quot; value=&quot;true&quot; /&gt;<br>                       &lt;property name=&quot;hibernate.current_session_context_class&quot; value=&quot;jta&quot; /&gt;<br>

                       &lt;property name=&quot;hibernate.connection.driver_class&quot;<br>value=&quot;oracle.jdbc.xa.client.OracleXADataSource&quot; /&gt;<br>                       &lt;property name=&quot;hibernate.jndi.class&quot;<br>

value=&quot;bitronix.tm.jndi.BitronixInitialContextFactory&quot;/&gt;<br>                       &lt;property name=&quot;hibernate.transaction.manager_lookup_class&quot;<br>value=&quot;org.hibernate.transaction.BTMTransactionManagerLookup&quot; /&gt;<br>

               &lt;/properties&gt;<br>       &lt;/persistence-unit&gt;<br><br>2. in my application context:<br>&lt;!--  Bitronix Transaction Manager embedded configuration --&gt;<br>       &lt;bean id=&quot;oracleDataSource&quot;<br>

class=&quot;bitronix.tm.resource.jdbc.PoolingDataSource&quot;<br>               init-method=&quot;init&quot; destroy-method=&quot;close&quot;&gt;<br>               &lt;property name=&quot;className&quot;<br>value=&quot;oracle.jdbc.xa.client.OracleXADataSource&quot; /&gt;<br>

               &lt;property name=&quot;uniqueName&quot; value=&quot;jdbc/DS1&quot; /&gt;<br>               &lt;property name=&quot;maxPoolSize&quot; value=&quot;5&quot; /&gt;<br>               &lt;property name=&quot;allowLocalTransactions&quot; value=&quot;true&quot; /&gt;<br>

               &lt;property name=&quot;testQuery&quot; value=&quot;SELECT 1 FROM DUAL&quot; /&gt;<br>               &lt;property name=&quot;driverProperties&quot;&gt;<br>                       &lt;props&gt;<br>                               &lt;prop key=&quot;user&quot;&gt;myuser&lt;/prop&gt;<br>

                               &lt;prop key=&quot;password&quot;&gt;myuser&lt;/prop&gt;<br>                               &lt;prop key=&quot;URL&quot;&gt;myurl&lt;/prop&gt;<br>                       &lt;/props&gt;<br>               &lt;/property&gt;<br>

       &lt;/bean&gt;<br><br><br>       &lt;bean id=&quot;btmConfig&quot; factory-method=&quot;getConfiguration&quot;<br>               class=&quot;bitronix.tm.TransactionManagerServices&quot;&gt;<br>               &lt;property name=&quot;serverId&quot; value=&quot;spring-btm&quot; /&gt;<br>

       &lt;/bean&gt;<br><br><br>       &lt;bean id=&quot;BitronixTransactionManager&quot;<br>factory-method=&quot;getTransactionManager&quot;<br>               class=&quot;bitronix.tm.TransactionManagerServices&quot; depends-on=&quot;btmConfig&quot;<br>

               destroy-method=&quot;shutdown&quot; /&gt;<br><br><br>       &lt;bean id=&quot;JtaTransactionManager&quot;<br>               class=&quot;org.springframework.transaction.jta.JtaTransactionManager&quot;&gt;<br>

               &lt;property name=&quot;transactionManager&quot; ref=&quot;BitronixTransactionManager&quot; /&gt;<br>               &lt;property name=&quot;userTransaction&quot; ref=&quot;BitronixTransactionManager&quot; /&gt;<br>

       &lt;/bean&gt;<br>       &lt;!-- end of Bitronix Transaction Manager embedded configuration --&gt;<br><br>3. and in the code:<br>EntityManagerFactory emf =<br>Persistence.createEntityManagerFactory(&quot;org.drools.persistence.jpa&quot;);<br>

               Environment env = KnowledgeBaseFactory.newEnvironment();<br>               env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);<br>               env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());<br>

               env.set(EnvironmentName.TRANSACTION_MANAGER,<br>TransactionManagerServices.getTransactionManager());<br>               ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null,<br>env);<br><br>

However in the last code I get:<br><br>Caused by: java.lang.IllegalStateException:<br>java.lang.reflect.InvocationTargetException<br>       at<br>org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:130)<br>

       at<br>org.drools.persistence.jpa.KnowledgeStoreServiceImpl.newStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:54)<br>       at<br>org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:109)<br>

       at<br>com.mycompany.util.BookWorkflowUtilities.createSession(BookWorkflowUtilities.java:83)<br>       at com.mycompany.util.BookWorkflowService.init(BookWorkflowService.java:62)<br>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>

       at<br>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>       at<br>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>       at java.lang.reflect.Method.invoke(Method.java:597)<br>

       at<br>org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340)<br>       at<br>org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293)<br>

       at<br>org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130)<br>       ... 29 more<br>Caused by: java.lang.reflect.InvocationTargetException<br>

       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br>       at<br>sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)<br>       at<br>sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)<br>

       at java.lang.reflect.Constructor.newInstance(Constructor.java:513)<br>       at<br>org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)<br>       ... 40 more<br>

Caused by: java.lang.RuntimeException: Could not commit session or rollback<br>       at<br>org.drools.persistence.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:133)<br>       ... 45 more<br>Caused by: java.lang.RuntimeException: Unable to rollback transaction<br>

       at<br>org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:184)<br>       at<br>org.drools.persistence.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:131)<br>

       ... 45 more<br>Caused by: java.lang.NullPointerException<br>       at<br>org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)<br></div></div><span style="color:#888888"><div><div>

</div><div class="h5"><br>--<br>View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-NullPointerException-at-org-drools-persistence-jta-JtaTransactionManager-rollbac-tp2602190p2602190.html?by-user=t&amp;by-user=t" rel="nofollow" link="external" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-NullPointerException-at-org-drools-persistence-jta-JtaTransactionManager-rollbac-tp2602190p2602190.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<br>_______________________________________________<br>rules-users mailing list<br></div></div><a href="http://user/SendEmail.jtp?type=node&amp;node=2602731&amp;i=1&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a><div class="im">

<br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></div></span><p></p></div><p class="MsoNormal"> </p>

</div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_______________________________________________ <br>rules-users mailing list <br><a href="http://user/SendEmail.jtp?type=node&amp;node=2602731&amp;i=2&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a> <br>

</p><div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></div><p></p><div class="MsoNormal" align="center" style="text-align:center">

<hr size="1" width="100%" noshade style="color:#CCCCCC" align="center"></div><div><div><p class="MsoNormal"><b><span style="font-size:9.0pt;color:#444444">If you reply to this email, your message will be added to the discussion below:</span></b></p>

</div><p class="MsoNormal"><span style="font-size:9.0pt;color:#444444"><a href="http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-NullPointerException-at-org-drools-persistence-jta-JtaTransactionManager-rollbac-tp2602190p2602731.html?by-user=t" rel="nofollow" link="external" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-NullPointerException-at-org-drools-persistence-jta-JtaTransactionManager-rollbac-tp2602190p2602731.html</a> </span></p>

</div><div style="margin-top:4.8pt"><p class="MsoNormal"><span style="font-size:8.5pt;color:#666666">
        
<br></span></p><hr align="left" width="300">
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Caused-by-java-lang-NullPointerException-at-org-drools-persistence-jta-JtaTransactionManager-rollbac-tp2602190p2602869.html" target="_blank">RE: Caused by: java.lang.NullPointerException at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:181)</a><div class="im">

<br>
Sent from the <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Drools-User-f47000.html" target="_blank">Drools - User mailing list archive</a> at Nabble.com.<br></div><p></p></div></div><br>_______________________________________________<br>


rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>