5 Replies Latest reply on Aug 28, 2008 9:06 AM by Sascha Becher

    Adding multiple last resources is disallowed

    shapirod Newbie

      Hello all.

      I recently upgraded from JBoss 4.0.1-sp1 to 4.2.2.GA and I've encountered this vexing problem that is beyond my experience.

      I'm using a local-tx-datasource defined as follows:

      <local-tx-datasource>
       <jndi-name>TXOnBoard</jndi-name>
       <connection-url>jdbc:sqlserver://anyserver:1433;DatabaseName=OnBoard;selectMethod=cursor</connection-url>
       <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
       <user-name>any</user-name>
       < password>any</ password>
      
       <transaction-isolation>TRANSACTION_READ_UNCOMMITTED</transaction-isolation>
      
       <new-connection-sql>SELECT COUNT(*) FROM OuidKey</new-connection-sql>
       <check-valid-connection-sql>SELECT COUNT(*) FROM OuidKey</check-valid-connection-sql>
       <min-pool-size>10</min-pool-size>
       <max-pool-size>2000</max-pool-size>
       <idle-timeout-minutes>15</idle-timeout-minutes>
       <metadata>
       <type-mapping>MS SQLSERVER2005</type-mapping>
       </metadata>
       </local-tx-datasource>


      In an ejb 2.0 bean managed message bean (though this problem occurs everywhere...)

      <message-driven>
       <ejb-name>SwitchTaskMessageBean</ejb-name>
       <ejb-class>com.agilquest.onboard.business.message.switchtask.SwitchTaskMessageBean</ejb-class>
       <transaction-type>Bean</transaction-type>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       <env-entry>
       <env-entry-name>TXDatasourceName</env-entry-name>
       <env-entry-type>java.lang.String </env-entry-type>
       <env-entry-value>java:/TXOnBoard</env-entry-value>
       </env-entry>
       </message-driven>
      

      When I try to enlist the datasource in a transaction (as in the following code):
       private void createSwitchTaskView(SwitchTaskData _onTask,
       SwitchTaskData _offTask)
       throws CreateException,
       SystemException {
       log__.trace("IN SwitchTaskMessageBean::createSwitchTaskView");
       UserTransaction trnx = null;
       DbTransConnection dbConn = null;
       SwitchTaskSQL swSql = getSwitchTaskSQL();
      
       // Flag for determining if an error occurred for transaction management
       boolean error = true;
      
       try {
      
       // Begin a transaction.
       trnx = getMessageDrivenContext().getUserTransaction();
       trnx.begin();
      
       // Create the switch task pair
       dbConn = getTxDbConnection();
       swSql.insertSwitchTasks(dbConn, _onTask, _offTask);
      
       // We're here so no errors occurred
       error = false;
       }
       catch (javax.transaction.NotSupportedException e) {
       throw new SystemException("NotSupportedException", e);
       }
       catch (javax.transaction.SystemException e) {
       throw new SystemException("javax.transaction.SystemException", e);
       }
       finally {
       // Take care of this transaction
       if (trnx != null) {
       try {
       // Determine if we need to commit or rollback
       if (!error) {
       trnx.commit();
       }
       else {
       trnx.rollback();
       }
       }
       catch (Exception e) {
       }
       }
       if (dbConn != null) {
       dbConn.close();
       }
       log__.trace("OUT SwitchTaskMessageBean::createSwitchTaskView");
       }
       }
      

      I get this error!


      09:42:37,180 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@11465dc
      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: -2e36dea7:960:47b5a380:7e 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: -2e36dea7:960:47b5a380:7e status: ActionStatus.ABORT_ONLY >))
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
      at com.agilquest.common.db.DbConnection.(DbConnection.java:34)
      at com.agilquest.common.db.DbTransConnection.(DbTransConnection.java:17)
      at com.agilquest.common.util.jndi.JndiUtil.getDbTransConnection(JndiUtil.java:257)
      at com.agilquest.onboard.util.JndiHelper.getDbTransConnection(JndiHelper.java:219)
      at com.agilquest.onboard.business.message.OnBoardMessageAdaptor.getTxDbConnection(OnBoardMessageAdaptor.java:186)
      at com.agilquest.onboard.business.message.switchtask.SwitchTaskMessageBean.archiveSwitchView(SwitchTaskMessageBean.java:3025)
      at com.agilquest.onboard.business.message.switchtask.SwitchTaskMessageBean.doProcessStatusTasks(SwitchTaskMessageBean.java:938)
      at com.agilquest.onboard.business.message.switchtask.SwitchTaskMessageBean.onMessage(SwitchTaskMessageBean.java:244)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
      at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:495)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
      at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:173)
      at org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT.invoke(MessageDrivenTxInterceptorBMT.java:47)
      at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:116)
      at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:109)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
      at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:402)
      at org.jboss.ejb.Container.invoke(Container.java:960)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:987)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1287)
      at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)
      at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:891)
      at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
      at org.jboss.mq.SpySession.run(SpySession.java:323)
      at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
      at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
      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: -2e36dea7:960:47b5a380:7e status: ActionStatus.ABORT_ONLY >)
      at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:343)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:518)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:399)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      ... 34 more
      Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -2e36dea7:960:47b5a380:7e status: ActionStatus.ABORT_ONLY >
      at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:744)
      at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:577)
      at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:337)
      ... 38 more


      If I set this property in jbossjta-properties.xml :
      <property name="com.arjuna.ats.jta.allowMultipleLastResources" value="true"/>
      

      I get the following:

      WARN [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@11f2108

      I'm baffled. What has changed so dramatically from 4.0.1-sp1 to 4.2.2.GA? And what do I need to do to make these transactions work the way they've always worked?

      Thanks in advance for helping us out.

      Daniel Shapiro
      Agilquest, Inc.