Unexpected behavior on Sybase EAServer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected behavior on Sybase EAServer

cmathrusse
I've been running on EAServer for some time now, (not willingly) and everything has been operating successfully until my latest build. After deployment I am getting an exception from the transaction manager complaining about nested transaction when attempting to connect to ActiveMQ. You'll find the trace listed below. The odd thing is that I have made no changes to the ActiveMQ libraries not have I changed anything related to BTM or Spring. Interestingly enough, I am able to deploy to Tomcat 5.5 without any issues. This exception does not get raised at all and my application is connecting to the same ActiveMQ instance and database instance. The only difference between the two deployments is the application server. I am hesitant about deploying into Production with my latest changes as I am seeing these exceptions occur in our test environment.


2008-03-24 11:25:04.509 ERROR pool-2-thread-2 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:04.511 ERROR pool-2-thread-1 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1 [DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     Caused by: org.springframework.transaction.NestedTransactionNotSupportedException: JTA implementation does not support nested transactions; nested exception is javax.transaction.NotSupportedException: Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:846)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:231)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:817)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.lang.Thread.run(Thread.java:595)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | Caused by: javax.transaction.NotSupportedException: Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at com.sybase.djc.transaction.UserTransaction.begin(UserTransaction.java:30)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:885)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:842)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | ... 7 more
2008-03-24 11:25:09.562 INFO  pool-2-thread-1 [DefaultMessageListenerContainer] Successfully refreshed JMS Connection
2008-03-24 11:25:09.570 ERROR pool-2-thread-12 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.624 ERROR pool-2-thread-14 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.632 ERROR pool-2-thread-7 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.633 ERROR pool-2-thread-6 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.642 ERROR pool-2-thread-9 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:13.312 INFO  ScheduledTask:AutoRefresh [AbstractRuleSource] Registering RuleExecutionSet: com.sybase.it.cosmos.rules.amer
2008-03-24 11:25:13.312 INFO  ScheduledTask:AutoRefresh [AbstractRuleSource] RuleExecutionSet Registered with URI: northAmerica
2008-03-24 11:25:14.631 ERROR pool-2-thread-13 [DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     Caused by: javax.jms.JMSException: error enlisting a MessageConsumerWrapper of a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool ActiveMQXAConnectionFactory in state ACCESSIBLE with underlying connection ActiveMQConnection {id=ID:revsysdev-36189-1206383059620-1:0,clientId=ID:revsysdev-36189-1206383059620-2:0,started=true} with 1 opened session(s)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.enlistResource(MessageConsumerWrapper.java:44)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.receive(MessageConsumerWrapper.java:63)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:375)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:300)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:234)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:817)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.lang.Thread.run(Thread.java:595)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | Caused by: bitronix.tm.internal.BitronixSystemException: resource 'ActiveMQXAConnectionFactory' cannot be used outside XA transaction scope. Set allowLocalTransactions to true if you want to allow this and you know your resource supports this.
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.common.TransactionContextHelper.enlistInCurrentTransaction(TransactionContextHelper.java:59)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.enlistResource(MessageConsumerWrapper.java:42)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | ... 9 more
2008-03-24 11:25:14.632 INFO  pool-2-thread-13 [DefaultMessageListenerContainer] Successfully refreshed JMS Connection
2008-03-24 11:25:14.634 ERROR pool-2-thread-7 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.636 ERROR pool-2-thread-14 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.642 ERROR pool-2-thread-6 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.643 ERROR pool-2-thread-15 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.655 ERROR pool-2-thread-8 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.656 ERROR pool-2-thread-9 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.657 ERROR pool-2-thread-12 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected behavior on Sybase EAServer

cmathrusse
Found it. Once I upgraded to Spring 2.5 I began to see error messages from Spring when setting the Bitronix Transaction Manager on the JtaTransactionManager class of Spring's. Even though I was supplying the constructor with the Bitronix TM I was seeing AmbigiousClass messages upon startup. (Spring was getting confused due the the Bitronix TM implements both TransactionManager and UserTransaction interfaces)

The solution was to change my configuration to use the no arg constructor of Springs JtaTransactionManager and set the BTM using the setTransactionManager method:

  <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
    <property name="transactionManager">
      <ref local="bitronixTransactionManager"/>
    </property>
  </bean> 


The problem is that even when you set the TM this way the UserTransaction object in the class remains null and in the afterPropertiesSet() method is invoked the UserTransaction, when NULL, is attempted to be acquired from JNDI. To override this you must invoke the setAutodetectTransactionManager = false as show below.

  <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
    <property name="autodetectTransactionManager" value="false"/>
    <property name="transactionManager">
      <ref local="bitronixTransactionManager"/>
    </property>
  </bean> 

This will force the JtaTransactionManager to build the UserTransaction using the specified TransactionManager. On my EAServer instances the UserTransaction was available via JNDI but on my Tomcat installs it was not, so the JtaTransactionManager was retrieving the UserTransaction from EAServer's JNDI which was causing the exception.

cmathrusse wrote
I've been running on EAServer for some time now, (not willingly) and everything has been operating successfully until my latest build. After deployment I am getting an exception from the transaction manager complaining about nested transaction when attempting to connect to ActiveMQ. You'll find the trace listed below. The odd thing is that I have made no changes to the ActiveMQ libraries not have I changed anything related to BTM or Spring. Interestingly enough, I am able to deploy to Tomcat 5.5 without any issues. This exception does not get raised at all and my application is connecting to the same ActiveMQ instance and database instance. The only difference between the two deployments is the application server. I am hesitant about deploying into Production with my latest changes as I am seeing these exceptions occur in our test environment.


2008-03-24 11:25:04.509 ERROR pool-2-thread-2 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:04.511 ERROR pool-2-thread-1 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1 [DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     Caused by: org.springframework.transaction.NestedTransactionNotSupportedException: JTA implementation does not support nested transactions; nested exception is javax.transaction.NotSupportedException: Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:846)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:231)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:817)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at java.lang.Thread.run(Thread.java:595)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | Caused by: javax.transaction.NotSupportedException: Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at com.sybase.djc.transaction.UserTransaction.begin(UserTransaction.java:30)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doJtaBegin(JtaTransactionManager.java:885)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | at org.springframework.transaction.jta.JtaTransactionManager.doBegin(JtaTransactionManager.java:842)
2008-03-24 11:25:09.561 ERROR pool-2-thread-1     | ... 7 more
2008-03-24 11:25:09.562 INFO  pool-2-thread-1 [DefaultMessageListenerContainer] Successfully refreshed JMS Connection
2008-03-24 11:25:09.570 ERROR pool-2-thread-12 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.624 ERROR pool-2-thread-14 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.632 ERROR pool-2-thread-7 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.633 ERROR pool-2-thread-6 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:09.642 ERROR pool-2-thread-9 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:13.312 INFO  ScheduledTask:AutoRefresh [AbstractRuleSource] Registering RuleExecutionSet: com.sybase.it.cosmos.rules.amer
2008-03-24 11:25:13.312 INFO  ScheduledTask:AutoRefresh [AbstractRuleSource] RuleExecutionSet Registered with URI: northAmerica
2008-03-24 11:25:14.631 ERROR pool-2-thread-13 [DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     Caused by: javax.jms.JMSException: error enlisting a MessageConsumerWrapper of a DualSessionWrapper in state ACCESSIBLE of a JmsPooledConnection of pool ActiveMQXAConnectionFactory in state ACCESSIBLE with underlying connection ActiveMQConnection {id=ID:revsysdev-36189-1206383059620-1:0,clientId=ID:revsysdev-36189-1206383059620-2:0,started=true} with 1 opened session(s)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.enlistResource(MessageConsumerWrapper.java:44)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.receive(MessageConsumerWrapper.java:63)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:375)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:300)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:234)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:870)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:817)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at java.lang.Thread.run(Thread.java:595)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | Caused by: bitronix.tm.internal.BitronixSystemException: resource 'ActiveMQXAConnectionFactory' cannot be used outside XA transaction scope. Set allowLocalTransactions to true if you want to allow this and you know your resource supports this.
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.common.TransactionContextHelper.enlistInCurrentTransaction(TransactionContextHelper.java:59)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | at bitronix.tm.resource.jms.MessageConsumerWrapper.enlistResource(MessageConsumerWrapper.java:42)
2008-03-24 11:25:14.631 ERROR pool-2-thread-13     | ... 9 more
2008-03-24 11:25:14.632 INFO  pool-2-thread-13 [DefaultMessageListenerContainer] Successfully refreshed JMS Connection
2008-03-24 11:25:14.634 ERROR pool-2-thread-7 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.636 ERROR pool-2-thread-14 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.642 ERROR pool-2-thread-6 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.643 ERROR pool-2-thread-15 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.655 ERROR pool-2-thread-8 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.656 ERROR pool-2-thread-9 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted.
2008-03-24 11:25:14.657 ERROR pool-2-thread-12 [TransactionManager] Failed to begin transaction as another transaction is active. Nested transactions are not supportted
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected behavior on Sybase EAServer

Ludovic Orban
Administrator
Hi Chris,

Nice problem you just spotted here. Thanks for reporting it and for the solution as well.

I find it strange that this was working with Spring 2.0 but not anymore with 2.5. Any idea why ? Also did you manage to exactly pinpoint why you got 'Nested transactions are not supported' exceptions (which means begin() is called more than once) ?

Don't you think it would be worth reporting this problem to the Spring developers ?

Thanks,
Ludovic
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected behavior on Sybase EAServer

cmathrusse
This post was updated on .
Hi Ludovic,

Good to hear from you. This was not an issue with Spring at all. It was simply a configuration issue. The long story is that when I upgraded to Spring 2.5, and for some reason it did not happen right away, I started seeing errors on application startup. It seems that Spring was unable to identify the correct Constructor in the JtaTransactionManager when I was supplying the BitronixTransactionManager as its argument. If you look at the JtaTransactionManager you will find several Constructors; one with no args, one with a TransactionManager, one with a UserTransaction, and one that takes both a UserTransaction and a TransacitonManager. Spring was unable to figure out which Constructor to invoke as the BitronixTransactionManager implements both TransactionManager and UserTransaction. I tried specifying the type but it did not seem to help.

The solution seemed easy; use the no arg Constructor and then set the TransactionManager. But this produced an unexpected problem. When the afterPropertiesSet() method is invoked and the UserTransaction object is null, by default Spring will attempt to retrieve the UserTransaction from JNDI. On my Tomcat server there was no UserTransaction bound so the JtaTransactionManager simply builds a UserTransaction object internally using the TransactionManager. But when I deployed to EAServer there was a UserTransaction object bound and it was retrieved and set on the JtaTransactionManager. This resulted in the class using the EAServer UserTransaction object without using the EAServer TransactionManager but rather the BitronixTransactionManager.

The solution was simple, just set the TransactionManager and the UserTransaction on the JtaTransactionManager class specifying the BitronixTransactionManager. Its not a bug in Spring but simply a mis-configuration issue. I guess I could have gotten around the issue as well by specifying autodetectUserTransaction = false on the JtaTransactionManager but this approach seemed to work well.