<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Spring + JBpm 5.2 + Bitronix - JTA Transaction not rolling back
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/jegan">S Jegan</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/714963#714963">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi All,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>We are using JBpm 5.2 with Spring 3 and Bitronix as transaction manager. JBpm is integrated inside our application, we use the LocalTaskService to create tasks etc. All JBpm relates tables are co-existing with our application. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And another thing is that, we do not use JPA, but rather Hibernate. So there is one datasource, an Entity Manager for JBpm and a SessionFactory for our application. We have configured JTA using Bitronix and spring. Below is the configuration.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p>&#160; &lt;bean id="transactionManager"</p><p>&#160;&#160;&#160; class="com.tarshan.onebill.common.bpm.service.JTATransactionMgr"&gt;</p><p>&#160;&#160;&#160; &lt;property name="transactionManager" ref="bitronixTransactionManager" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="userTransaction" ref="bitronixTransactionManager" /&gt;</p><p>&#160; &lt;/bean&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; &lt;bean id="btmConfig" factory-method="getConfiguration"</p><p>&#160;&#160;&#160; class="bitronix.tm.TransactionManagerServices"&gt;</p><p>&#160;&#160;&#160; &lt;property name="serverId" value="spring-btm" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="defaultTransactionTimeout" value="300" /&gt;</p><p>&#160; &lt;/bean&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; &lt;bean id="bitronixTransactionManager" factory-method="getTransactionManager"</p><p>&#160;&#160;&#160; class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"</p><p>&#160;&#160;&#160; destroy-method="shutdown"&gt;</p><p>&#160; &lt;/bean&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; &lt;bean id="jbpmDataSource" class="com.tarshan.onebill.common.bpm.vendor.jbpm.ObPoolingDataSource"</p><p>&#160;&#160;&#160; init-method="init" destroy-method="close"&gt;</p><p>&#160;&#160;&#160; &lt;property name="className" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="uniqueName" value="jdbc/jbpm" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="minPoolSize" value="1" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="maxPoolSize" value="3" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="acquisitionInterval" value="1" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="acquisitionTimeout" value="15" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="maxIdleTime" value="15" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="useTmJoin" value="true" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="deferConnectionRelease" value="true" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="automaticEnlistingEnabled" value="true" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="allowLocalTransactions" value="true" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="driverProperties" ref="driverProperties" /&gt;</p><p>&#160; &lt;/bean&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Entity Manager configuration:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p>&#160; &lt;bean id="entityMF2"</p><p>&#160;&#160;&#160; class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="btmConfig"&gt;</p><p>&#160;&#160;&#160; &lt;property name="dataSource" ref="jbpmDataSource" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="loadTimeWeaver"&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;bean</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /&gt;</p><p>&#160;&#160;&#160; &lt;/property&gt;</p><p>&#160;&#160;&#160; &lt;property name="persistenceUnitName" value="org.jbpm.persistence.jpa" /&gt;</p><p>&#160;&#160;&#160; &lt;property name="jpaVendorAdapter"&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;property name="showSql" value="true" /&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;/bean&gt;</p><p>&#160;&#160;&#160; &lt;/property&gt;</p><p>&#160;&#160;&#160; &lt;property name="jpaProperties"&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;props&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prop key="hibernate.connection.autocommit"&gt;false&lt;/prop&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prop key="hibernate.max_fetch_depth"&gt;3&lt;/prop&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prop key="hibernate.transaction.manager_lookup_class"&gt;org.hibernate.transaction.BTMTransactionManagerLookup</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/prop&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;prop key="hibernate.current_session_context_class"&gt;jta&lt;/prop&gt;</p><p>&#160;&#160;&#160;&#160;&#160; &lt;/props&gt;</p><p>&#160;&#160;&#160; &lt;/property&gt;</p><p>&#160; &lt;/bean&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now, we have a service which starts a process and then inserts some records in our application database. If any of the operation fails, JBpm is not rolling back the transaction. The weird thing is that, I could see from the log that Bitronix is rolling back the transaction. I could also see that JBpm is only joining the existing transaction at TaskServiceSession (because we have set transactionType as "local-JTA" while starting the task service).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{quote}</p><p>126224 07/02 18:46:01,358[main] DEBUG bpm.service.JTATransactionMgr.processRollback&#160; - Initiating transaction rollback</p><p>Inside doRollback</p><p>129134 07/02 18:46:04,268[main] DEBUG bitronix.tm.BitronixTransactionManager.debug&#160; - rolling back transaction a Bitronix Transaction with GTRID [737072696E672D62746D0000013557F39D0A00000000], status=ACTIVE, 1 resource(s) enlisted (started Tue Feb 07 18:44:37 IST 2012)</p><p>129135 07/02 18:46:04,269[main] DEBUG tm.timer.TaskScheduler.debug&#160; - cancelling transaction timeout task on a Bitronix Transaction with GTRID [737072696E672D62746D0000013557F39D0A00000000], status=ACTIVE, 1 resource(s) enlisted (started Tue Feb 07 18:44:37 IST 2012)</p><p>129136 07/02 18:46:04,270[main] DEBUG tm.timer.TaskScheduler.debug&#160; - removing task by a Bitronix Transaction with GTRID [737072696E672D62746D0000013557F39D0A00000000], status=ACTIVE, 1 resource(s) enlisted (started Tue Feb 07 18:44:37 IST 2012)</p><p>{quote}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I am really not clear why the records are still persisted in JBpm tables. Please help me fix this issue. Not sure what I am doing wrong. I could be missing something very basic. Have also uploaded the persistence.xml file.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks for your time.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Regards,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Jegan</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/714963#714963">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>