4 Replies Latest reply: Oct 9, 2013 10:59 AM by John Francis RSS

Problems with using the TXBridge to coordinate 2 Stateless Session Beans using different XA DataSources

John Francis Newbie

I am using JBoss AS 7.1.1.Final (standalone, xts configured), Java 1.7 and Windows 7 x64. I am running up JBoss from Eclipse.

 

SQLServer version: Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

JDBC Driver Microsfts version 4 driver: download  sqljdbc_4.0.2206.100_enu.exe

 

The attached zip contains 8 Eclipse/Maven projects.

These build 2 Enterprise Apps JBTest4EAR and JBTest5EAR which contain 1 Stateless Session bean each, SSB4 and SSB5 respectively.

These SSB's each have a reference to a diffrent XADatasource which they use to get a JDBC connection to a database (unfortunately this is SQLServer2008R2 which is what I'm working with, and I have run out of time to try another database server)

Each bean uses a different database instance but for the test both have identical schemas, just as they have identical functionality.

There are 2 test projects

1/ JBTestClientFandF (FourAndFive ) is a straightforward standalone junit test case which runs outside of jboss (it could run as a command line app under maven)

This uses the standard JBoss JNDI lookup to get hold of 2 bean references 1 to each of SSB4 and SSB5.

It then grabs a UserTransaction  to control invocations of the SSBs and tests that the commits and rollbacks work as expected even though the transaction begin/commit/rollback spans both beans and 2 XA connections.

This junit test succeeds without any problems. The trace StandaloneTestClient.log shows the output.

2/ JBTestWebFandF contains a webapp which consists of a servlet whose doPost method invokes SSB4 and SSB5 using their WebService interfaces and the HandlerChains necessary for the txbridge.

The sequence of calls is the same as that carried out by the JUnit test in JBTestClientFandF.

If I run this it fails with the following error ( the full stack trace is attached in server.log )

 

 

=======================================================

 

 

17:56:30,309 WARN  [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (http-localhost-127.0.0.1-8080-2) IJ000305: Connection error occured: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@77ff67f[state=NORMAL managed connection=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@cd453a2 connection handles=0 lastUse=1379436974137 trackByTx=true pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@39f172da pool internal context=SemaphoreArrayListManagedConnectionPool@453d3874[pool=MSSQLDSXA2] xaResource=XAResourceWrapperImpl@2f890199[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@cd453a2 pad=false overrideRmValue=false productName=Microsoft SQL Server productVersion=10.50.2500 jndiName=java:/MSSQLDSXA2] txSync=null]: javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc.SQLServerException: The function START: failed. No transaction cookie was returned.

  at com.microsoft.sqlserver.jdbc.SQLServerXAResource.DTC_XA_Interface(SQLServerXAResource.java:647)

  at com.microsoft.sqlserver.jdbc.SQLServerXAResource.start(SQLServerXAResource.java:679)

  at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.start(XAManagedConnection.java:259)

  at org.jboss.jca.core.tx.jbossts.XAResourceWrapperImpl.start(XAResourceWrapperImpl.java:188)

  at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:636)

  at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:397)

  at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener$TransactionSynchronization.enlist(TxConnectionListener.java:587)

  at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.enlist(TxConnectionListener.java:264)

  at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.managedConnectionReconnected(TxConnectionManagerImpl.java:467)

  at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.reconnectManagedConnection(AbstractConnectionManager.java:599)

  at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:467)

  at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)

  at uk.co.his.test.ssb5.SSB5.add(SSB5.java:111) [JBTest5.jar:]

 

.... snip! ....

 

 

 

 

17:56:30,514 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) javax.transaction.SystemException: TransactionImple.enlistResource - XAResource.start ARJUNA016054: could not register transaction: < 131080, 29, 64, 0000000000-1-1-64-880-45-39-88-55248256-119-970007849, 292929292929292929292828-35-5929-16-10-59-265311185-90-68292929107782929292929292929292929292929292929292929292929292929292929292929292929 >

 

 

17:56:30,515 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:687)

 

 

17:56:30,516 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:397)

 

 

17:56:30,517 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener$TransactionSynchronization.enlist(TxConnectionListener.java:587)

 

 

17:56:30,517 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.enlist(TxConnectionListener.java:264)

 

 

17:56:30,518 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.managedConnectionReconnected(TxConnectionManagerImpl.java:467)

 

 

17:56:30,518 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.reconnectManagedConnection(AbstractConnectionManager.java:599)

 

 

17:56:30,519 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:467)

 

 

17:56:30,520 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)

 

 

17:56:30,520 ERROR [stderr] (http-localhost-127.0.0.1-8080-2) at uk.co.his.test.ssb5.SSB5.add(SSB5.java:111)

...snip! ...

 

 

==============================================================

 

 

It fails when the seond bean (SSB5) tries to connect to the database, the first bean (SSB4) having succeeded and returned control to the servlet.

If i run the test with both service references pointing to an SSB4 service instance it works fine ( though it moans about the incorrect results because it is now using the same database instance ).

 

 

 

 

 

 

So my question is

1) If this works when I invoke the SSBs as SSBs but not as a WebService is this a bug in the TXBridge? Or What am I doing wrong ? Or is this some weakness in the interaction between JBoss and SQLServer?

 

 

P.S. I have also included the standalone-xts.xml config I am using to show how the database is setup. Should anyone have any SQLServer 2008 servers setup for XA, the JBTestClientFandF will create the schema in the databases.

 

 

The following may prove useful;

 

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/15c1e6f5-ec1e-4376-8f45-25e61ffc1306/the-function-start-has-failed-no-transaction-cookie-was-returned

 

The instructions on setting up SQLServer for XA transactions http://technet.microsoft.com/en-us/library/aa342335(v=sql.105).aspx have the following comments which may be relevant (though the hotfix indicated is described as being for Windows 2003)

------------------------------------------------------------------------------------

The following additional guidelines apply to tightly coupled transactions:

  • When you use XA transactions together with Microsoft Distributed Transaction Coordinator (MS DTC), you may notice that the current version of MS DTC does not support tightly coupled XA branch behavior. For example, MS DTC has a one-to-one mapping between an XA branch transaction ID (XID) and an MS DTC transaction ID and the work that is performed by loosely coupled XA branches is isolated from one another.The hotfix provided at MSDTC and Tightly Coupled Transactions enables the support for tightly coupled XA branches where multiple XA branches with same global transaction ID (GTRID) are mapped to a single MS DTC transaction ID. This support enables multiple tightly coupled XA branches to see one another's changes in the resource manager, such as SQL Server.
  • A SSTRANSTIGHTLYCPLD flag allows the applications to use the tightly coupled XA transactions, which have different XA branch transaction IDs (XIDs) but have the same global transaction ID (GTRID). In order to use that feature, you must set the SSTRANSTIGHTLYCPLD on the flags parameter of the XAResource.start method:

     

     

    xaRes.start(xid, SQLServerXAResource.SSTRANSTIGHTLYCPLD); 

     

--------------------------------------------------------------------------------------

 

 

 

I would go further, but this is all the time I can spend on this for now.

 

 

 

Anyone?  Is this the wrong forum to be discussing this? No one any clues?