<!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;"> </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;"> </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;"> </p><p>{code:xml}</p><p>  <bean id="transactionManager"</p><p>    class="com.tarshan.onebill.common.bpm.service.JTATransactionMgr"></p><p>    <property name="transactionManager" ref="bitronixTransactionManager" /></p><p>    <property name="userTransaction" ref="bitronixTransactionManager" /></p><p>  </bean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <bean id="btmConfig" factory-method="getConfiguration"</p><p>    class="bitronix.tm.TransactionManagerServices"></p><p>    <property name="serverId" value="spring-btm" /></p><p>    <property name="defaultTransactionTimeout" value="300" /></p><p>  </bean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <bean id="bitronixTransactionManager" factory-method="getTransactionManager"</p><p>    class="bitronix.tm.TransactionManagerServices" depends-on="btmConfig"</p><p>    destroy-method="shutdown"></p><p>  </bean></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  <bean id="jbpmDataSource" class="com.tarshan.onebill.common.bpm.vendor.jbpm.ObPoolingDataSource"</p><p>    init-method="init" destroy-method="close"></p><p>    <property name="className" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" /></p><p>    <property name="uniqueName" value="jdbc/jbpm" /></p><p>    <property name="minPoolSize" value="1" /></p><p>    <property name="maxPoolSize" value="3" /></p><p>    <property name="acquisitionInterval" value="1" /></p><p>    <property name="acquisitionTimeout" value="15" /></p><p>    <property name="maxIdleTime" value="15" /></p><p>    <property name="useTmJoin" value="true" /></p><p>    <property name="deferConnectionRelease" value="true" /></p><p>    <property name="automaticEnlistingEnabled" value="true" /></p><p>    <property name="allowLocalTransactions" value="true" /></p><p>    <property name="driverProperties" ref="driverProperties" /></p><p>  </bean></p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Entity Manager configuration:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>{code:xml}</p><p>  <bean id="entityMF2"</p><p>    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="btmConfig"></p><p>    <property name="dataSource" ref="jbpmDataSource" /></p><p>    <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" /></p><p>    <property name="loadTimeWeaver"></p><p>      <bean</p><p>        class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" /></p><p>    </property></p><p>    <property name="persistenceUnitName" value="org.jbpm.persistence.jpa" /></p><p>    <property name="jpaVendorAdapter"></p><p>      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></p><p>        <property name="showSql" value="true" /></p><p>      </bean></p><p>    </property></p><p>    <property name="jpaProperties"></p><p>      <props></p><p>        <prop key="hibernate.connection.autocommit">false</prop></p><p>        <prop key="hibernate.max_fetch_depth">3</prop></p><p>        <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</p><p>        </prop></p><p>        <prop key="hibernate.show_sql">true</prop></p><p>        <prop key="hibernate.current_session_context_class">jta</prop></p><p>      </props></p><p>    </property></p><p>  </bean></p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;"> </p><p>{quote}</p><p>126224 07/02 18:46:01,358[main] DEBUG bpm.service.JTATransactionMgr.processRollback  - Initiating transaction rollback</p><p>Inside doRollback</p><p>129134 07/02 18:46:04,268[main] DEBUG bitronix.tm.BitronixTransactionManager.debug  - 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  - 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  - 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;"> </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;"> </p><p>Thanks for your time.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Regards,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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>