1 Reply Latest reply on Aug 24, 2009 4:43 AM by Rajika Kumarasiri

    Exception while using more that one datasource with JTA

    Rajika Kumarasiri Newbie

      hi,
      I am using JTA in my application and I deployed it in JBOSS5.1.0 GA on linux. I am using the UserTransaction interface and the JTA provider will be JBOSS JTA.
      I have two datasources defined for mysql but when I try to use them I am getting the following exception. For single datasource it works fine. Any help would be greatly appreciated.

      My two datasources configurations are like the below.



      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>MySQLDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/esbdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>test</user-name>
       <password>test123</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      
      


      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>MySQLDS1</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/esbdb</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>test</user-name>
       <password>test123</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>
      


      When I am trying to use those datasources I am end up with the following stack trance.


      11:54:54,022 WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] Adding multiple last resources is disallowed. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@1d1e05
      11:54:54,032 INFO [STDOUT] 11:54:54,031 ERROR [DBReportMediator] Error execuring insert statement : update company set price=? where name =? against DataSource : localhost:1099
      org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >))
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
       at org.apache.synapse.mediators.db.AbstractDBMediator.getPreparedStatement(AbstractDBMediator.java:177)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:40)
       at org.apache.synapse.mediators.db.AbstractDBMediator.mediate(AbstractDBMediator.java:102)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.filters.OutMediator.mediate(OutMediator.java:55)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
       at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:131)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
       at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
       at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:409)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:625)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:499)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
       ... 16 more
      Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:879)
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:675)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:403)
       ... 20 more
      11:54:54,033 INFO [STDOUT] 11:54:54,032 ERROR [SERVICE_LOGGER] Error execuring insert statement : update company set price=? where name =? against DataSource : localhost:1099
      org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >))
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
       at org.apache.synapse.mediators.db.AbstractDBMediator.getPreparedStatement(AbstractDBMediator.java:177)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:40)
       at org.apache.synapse.mediators.db.AbstractDBMediator.mediate(AbstractDBMediator.java:102)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.filters.OutMediator.mediate(OutMediator.java:55)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
       at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:131)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
       at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
       at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:409)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:625)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:499)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
       ... 16 more
      Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:879)
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:675)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:403)
       ... 20 more
      11:54:54,034 INFO [STDOUT] 11:54:54,034 WARN [FaultHandler] ERROR_CODE : 0
      11:54:54,034 INFO [STDOUT] 11:54:54,034 WARN [FaultHandler] ERROR_MESSAGE : Error execuring insert statement : update company set price=? where name =? against DataSource : localhost:1099
      11:54:54,041 INFO [STDOUT] 11:54:54,041 WARN [FaultHandler] ERROR_DETAIL : org.apache.synapse.SynapseException: Error execuring insert statement : update company set price=? where name =? against DataSource : localhost:1099
       at org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:275)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:61)
       at org.apache.synapse.mediators.db.AbstractDBMediator.mediate(AbstractDBMediator.java:102)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.filters.OutMediator.mediate(OutMediator.java:55)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:115)
       at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:131)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:339)
       at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:135)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:178)
       at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:230)
       at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:58)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >))
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
       at org.apache.synapse.mediators.db.AbstractDBMediator.getPreparedStatement(AbstractDBMediator.java:177)
       at org.apache.synapse.mediators.db.DBReportMediator.processStatement(DBReportMediator.java:40)
       ... 14 more
      Caused by: org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:409)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:625)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:499)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
       ... 16 more
      Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000001:95a2:4a9231db:6f status: ActionStatus.ABORT_ONLY >
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:879)
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:675)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:403)
       ... 20 more
      
      


      Please advice. Thanks!