Search code examples
sql-serverjpajdbcjbpm

"Multiple last resources have been added to the current transaction" warning despite using XA driver


My JBPMM/PAM application under JBoss has been getting intermittent optimistic lock exceptions so I wanted to make sure that my application's

Multiple last resources have been added to the current transaction

warnings are harmless. I get these warning despite using an XA driver and

<property name="com.arjuna.ats.arjuna.allowMultipleLastResources" value="true"/>

My application uses multiple datsources pointing to different databases via Hibernate and JPA. However, the XA driver used for querying our SQL Server DB seems like it should allow distributed transactions - so why does Arjuna still issue warnings? Is there a simple configuration change I can make to avoid these warnings?

<drivers>
       <driver name="sqlserver" module="com.microsoft.jdbc">
             <xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
       </driver>
</drivers> 

Solution

  • The reason here is that you are working with two datasources which are part of one global transactions - i.e., those will be the two different databases. The datasources are (most probably) configured as standard datasources and not XA datasources. Only XA datasource is capable to correctly participate within the XA transaction (transaction with multiple participants - https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/html-single/managing_transactions_on_jboss_eap/index#xa_versus_non_xa_transactions).

    The MSSQL implements the XA tranactions thus you could just need to change the datasource configuration to be configured as an XA datasource. https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/html-single/configuration_guide/index#example_microsoft_sqlserver_xa_datasource