<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=sgoyal" rel="nofollow">sumit goyal</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7926?redirect=false" rel="nofollow">SPR-7926</a></strong> and commented</p>
<p dir="auto">Greetings, We have a spring app, which listens to messages from a weblogic JMS. we are using weblogic client library 10.0.1, and Spring 3.0.3-Release. We use transaction'ed JMS sessions.</p>
<p dir="auto">It could possibly be a dup of <a href="https://jira.springframework.org/browse/SPR-7366" rel="nofollow">https://jira.springframework.org/browse/SPR-7366</a></p>
<p dir="auto">Can someone pls have a look at the stack trace of JMS Listener threads and comment? Your help will be much appreciated.</p>
<p dir="auto">Also adding my spring configuration below:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;bean id=&quot;messageListener&quot;
	class=&quot;org.springframework.jms.listener.adapter.MessageListenerAdapter&quot;&gt;
	&lt;constructor-arg&gt;
		&lt;bean class=&quot;com.eharmony.matching.mnssender.jms.DefaultDtoDelegate&quot; /&gt;
	&lt;/constructor-arg&gt;
	&lt;property name=&quot;defaultListenerMethod&quot; value=&quot;receive&quot; /&gt;
	&lt;property name=&quot;messageConverter&quot;&gt;
		&lt;bean class=&quot;com.eharmony.matching.mnssender.jms.Converter&quot; /&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id=&quot;jmsListenerContainer&quot;
	class=&quot;org.springframework.jms.listener.DefaultMessageListenerContainer&quot;&gt;
	&lt;property name=&quot;concurrentConsumers&quot; value=&quot;${MNSClient.jms.concurrent.consumers}&quot; /&gt;
	&lt;property name=&quot;connectionFactory&quot; ref=&quot;jmsQueueConnectionFactory&quot; /&gt;
	&lt;property name=&quot;destination&quot; ref=&quot;queue&quot; /&gt;
	&lt;property name=&quot;sessionTransacted&quot; value=&quot;true&quot; /&gt;
	&lt;property name=&quot;messageListener&quot; ref=&quot;messageListener&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;jmsQueueConnectionFactory&quot;
	class=&quot;org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter&quot;&gt;
	&lt;property name=&quot;targetConnectionFactory&quot;&gt;
		&lt;ref bean=&quot;internalJmsQueueConnectionFactory&quot; /&gt;
	&lt;/property&gt;
	&lt;property name=&quot;username&quot;&gt;
		&lt;value&gt;${MNSClient.receive.jms.user}&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name=&quot;password&quot;&gt;
		&lt;value&gt;${MNSClient.receive.jms.password}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id=&quot;internalJmsQueueConnectionFactory&quot; class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&gt;
	&lt;property name=&quot;jndiTemplate&quot;&gt;
		&lt;ref bean=&quot;jndiTemplate&quot; /&gt;
	&lt;/property&gt;
	&lt;property name=&quot;jndiName&quot;&gt;
		&lt;value&gt;${MNSClient.receive.jms.connectionFactoryName}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!-- RECEIVING JMS MESSAGE --&gt;
&lt;bean id=&quot;jndiTemplate&quot; class=&quot;org.springframework.jndi.JndiTemplate&quot;&gt;
	&lt;property name=&quot;environment&quot;&gt;
		&lt;props&gt;
			&lt;prop key=&quot;java.naming.factory.initial&quot;&gt;${MNSClient.receive.jms.initialFactoryName}&lt;/prop&gt;
			&lt;prop key=&quot;java.naming.provider.url&quot;&gt;${MNSClient.receive.jms.providerUrl}&lt;/prop&gt;
		&lt;/props&gt;
	&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id=&quot;queue&quot; class=&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;&gt;
	&lt;property name=&quot;jndiTemplate&quot;&gt;
		&lt;ref bean=&quot;jndiTemplate&quot; /&gt;
	&lt;/property&gt;
	&lt;property name=&quot;jndiName&quot;&gt;
		&lt;value&gt;${MNSClient.receive.jms.queueName}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;"><pre class="notranslate"><code class="notranslate">&lt;bean id="messageListener"
	class="org.springframework.jms.listener.adapter.MessageListenerAdapter"&gt;
	&lt;constructor-arg&gt;
		&lt;bean class="com.eharmony.matching.mnssender.jms.DefaultDtoDelegate" /&gt;
	&lt;/constructor-arg&gt;
	&lt;property name="defaultListenerMethod" value="receive" /&gt;
	&lt;property name="messageConverter"&gt;
		&lt;bean class="com.eharmony.matching.mnssender.jms.Converter" /&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="jmsListenerContainer"
	class="org.springframework.jms.listener.DefaultMessageListenerContainer"&gt;
	&lt;property name="concurrentConsumers" value="${MNSClient.jms.concurrent.consumers}" /&gt;
	&lt;property name="connectionFactory" ref="jmsQueueConnectionFactory" /&gt;
	&lt;property name="destination" ref="queue" /&gt;
	&lt;property name="sessionTransacted" value="true" /&gt;
	&lt;property name="messageListener" ref="messageListener" /&gt;
&lt;/bean&gt;

&lt;bean id="jmsQueueConnectionFactory"
	class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"&gt;
	&lt;property name="targetConnectionFactory"&gt;
		&lt;ref bean="internalJmsQueueConnectionFactory" /&gt;
	&lt;/property&gt;
	&lt;property name="username"&gt;
		&lt;value&gt;${MNSClient.receive.jms.user}&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="password"&gt;
		&lt;value&gt;${MNSClient.receive.jms.password}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="internalJmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
	&lt;property name="jndiTemplate"&gt;
		&lt;ref bean="jndiTemplate" /&gt;
	&lt;/property&gt;
	&lt;property name="jndiName"&gt;
		&lt;value&gt;${MNSClient.receive.jms.connectionFactoryName}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!-- RECEIVING JMS MESSAGE --&gt;
&lt;bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"&gt;
	&lt;property name="environment"&gt;
		&lt;props&gt;
			&lt;prop key="java.naming.factory.initial"&gt;${MNSClient.receive.jms.initialFactoryName}&lt;/prop&gt;
			&lt;prop key="java.naming.provider.url"&gt;${MNSClient.receive.jms.providerUrl}&lt;/prop&gt;
		&lt;/props&gt;
	&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="queue" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
	&lt;property name="jndiTemplate"&gt;
		&lt;ref bean="jndiTemplate" /&gt;
	&lt;/property&gt;
	&lt;property name="jndiName"&gt;
		&lt;value&gt;${MNSClient.receive.jms.queueName}&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;
</code></pre></div>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.3</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17558/threadDump.txt" rel="nofollow">threadDump.txt</a> (<em>161.63 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398106175" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12024" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12024/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12024">#12024</a> DefaultMessageListenerContainer transacted session race condition if no messages for a while when using shared/cached sessions (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=gregthoen" rel="nofollow">Greg Thoenen</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7366?redirect=false" rel="nofollow">SPR-7366</a></strong> and commented</p>
<p dir="auto">When using a DefaultMessageListenerContainer with transacted sessions, such as that created by the following spring integration bean definition:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;jms:message-driven-channel-adapter id=&quot;inboundChannelAdapter&quot;
    destination-resolver=&quot;jmsDestinationResolver&quot; destination-name=&quot;jms/myqueue&quot;
    connection-factory=&quot;jmsQueueConnectionFactory&quot;
    concurrent-consumers=&quot;4&quot; max-concurrent-consumers=&quot;4&quot; max-messages-per-task=&quot;1&quot;
    channel=&quot;importProcessChannel&quot; acknowledge=&quot;transacted&quot; 
/&gt;"><pre class="notranslate"><code class="notranslate">&lt;jms:message-driven-channel-adapter id="inboundChannelAdapter"
    destination-resolver="jmsDestinationResolver" destination-name="jms/myqueue"
    connection-factory="jmsQueueConnectionFactory"
    concurrent-consumers="4" max-concurrent-consumers="4" max-messages-per-task="1"
    channel="importProcessChannel" acknowledge="transacted" 
/&gt;
</code></pre></div>
<p dir="auto">If you receive no messages on the queue for whatever you have your transaction timeout set for your QueueConnectionFactory (it's one hour by default in Weblogic 10.3), you will see messages like this in the logs (as <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398078727" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8267" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8267/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8267">#8267</a> also seemed to be talking about):</p>
<p dir="auto">2010-07-01 15:49:21,304 INFO  [tid=2242,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure():747] Setup of JMS message listener invoker failed for destination 'jms/myqueue' - trying to recover. Cause: Attempt to resume an inactive transaction: BEA1-000598DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000598DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)<br>
at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:870)<br>
at weblogic.jms.client.JMSConsumer.receiveInternal(JMSConsumer.java:644)<br>
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:523)<br>
at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:184)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:405)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)<br>
at java.lang.Thread.run(Thread.java:619)<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000598DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)<br>
at weblogic.jms.dispatcher.Request.getResult(Request.java:52)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1124)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59)<br>
... 10 more<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000598DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2062)<br>
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2077)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2178)<br>
at weblogic.jms.frontend.FEConsumer.receive(FEConsumer.java:553)<br>
at weblogic.jms.frontend.FEConsumer.invoke(FEConsumer.java:805)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)<br>
... 13 more<br>
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-000598DE4AF4FDE2FECA<br>
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)<br>
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:376)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2123)<br>
... 16 more<br>
2010-07-01 15:49:21,351 INFO  [tid=2242,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful():791] Successfully refreshed JMS Connection<br>
2010-07-01 15:49:21,367 DEBUG [tid=2243,tgn=Pooled Threads] [springframework.jms.support.destination.JndiDestinationResolver.lookup():111] Located object with JNDI name [jms/myqueue]</p>
<p dir="auto">This will repeat every hour on the hour (or whatever you have your QueueConnectionFactory's transaction timeout set to) if you have no messages on the queue to receive for that hour, which is annoying, but not a big deal.  The main problem is that if you happen to receive a message right before the transaction timeout would occur - say, at 59 minutes and 50 seconds - and it takes more than 10 seconds to process the message, the JMS transaction will timeout so the message gets redelivered to another consumer while the first consumer still successfully processes it -- and because XA transactions are not being used, the db work from the first delivery commits before it tries to commit the JMS session [which throws an exception], and the 2nd delivery also succeeds so that you end up successfully processing the message twice.  Here's some output demonstrating this, where, for ease of reproducing, I set my QueueConnectionFactory transaction timeout to 5 minutes then purposely put a message on the queue a few seconds before I expected to have an "inactive transaction" message like above.  The receiver of the message is just sleeping for a random time b/w 2 and 3 minutes (so, it should be within the transaction timeout of 5 minutes, but the problem is that it gets picked up a few minutes into the transaction [i.e. since the last session commit/rollback].  Note that the "tid=" part in the log lines is the thread id, for help in showing what thread is doing what.</p>
<p dir="auto">2010-07-01 15:53:33,839 DEBUG [tid=3719,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.doReceiveAndExecute():311] Received message of type [class weblogic.jms.common.ObjectMessageImpl] from consumer [weblogic.jms.client.WLConsumerImpl@23fea4a] of session [weblogic.jms.client.WLSessionImpl@23fe6da]<br>
2010-07-01 15:53:34,198 INFO  [tid=3719,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():132] message received from queue: testmessage1<br>
2010-07-01 15:53:34,198 INFO  [tid=3719,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():137] sleeping<br>
2010-07-01 15:54:32,074 INFO  [tid=3798,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure():747] Setup of JMS message listener invoker failed for destination 'jms/myqueue' - trying to recover. Cause: Attempt to resume an inactive transaction: BEA1-000B98DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000B98DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)<br>
at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:870)<br>
at weblogic.jms.client.JMSConsumer.receiveInternal(JMSConsumer.java:644)<br>
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:523)<br>
at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:184)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:405)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)<br>
at java.lang.Thread.run(Thread.java:619)<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000B98DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)<br>
at weblogic.jms.dispatcher.Request.getResult(Request.java:52)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1124)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59)<br>
... 10 more<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000B98DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2062)<br>
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2077)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2178)<br>
at weblogic.jms.frontend.FEConsumer.receive(FEConsumer.java:553)<br>
at weblogic.jms.frontend.FEConsumer.invoke(FEConsumer.java:805)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)<br>
... 13 more<br>
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-000B98DE4AF4FDE2FECA<br>
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)<br>
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:376)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2123)<br>
... 16 more<br>
2010-07-01 15:54:32,074 INFO  [tid=3798,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful():791] Successfully refreshed JMS Connection<br>
2010-07-01 15:54:32,074 DEBUG [tid=3804,tgn=Pooled Threads] [springframework.jms.support.destination.JndiDestinationResolver.lookup():111] Located object with JNDI name [jms/myqueue]<br>
2010-07-01 15:54:47,855 DEBUG [tid=3802,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure():739] Setup of JMS message listener invoker failed - already recovered by other invoker<br>
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000898DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)<br>
at weblogic.jms.client.JMSSession.receiveMessage(JMSSession.java:870)<br>
at weblogic.jms.client.JMSConsumer.receiveInternal(JMSConsumer.java:644)<br>
at weblogic.jms.client.JMSConsumer.receive(JMSConsumer.java:523)<br>
at weblogic.jms.client.WLConsumerImpl.receive(WLConsumerImpl.java:184)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:405)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)<br>
at java.lang.Thread.run(Thread.java:619)<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000898DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)<br>
at weblogic.jms.dispatcher.Request.getResult(Request.java:52)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1124)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59)<br>
... 10 more<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000898DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2062)<br>
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2077)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2178)<br>
at weblogic.jms.frontend.FEConsumer.receive(FEConsumer.java:553)<br>
at weblogic.jms.frontend.FEConsumer.invoke(FEConsumer.java:805)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)<br>
... 13 more<br>
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-000898DE4AF4FDE2FECA<br>
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)<br>
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:376)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2123)<br>
... 16 more<br>
2010-07-01 15:54:47,871 DEBUG [tid=3805,tgn=Pooled Threads] [springframework.jms.support.destination.JndiDestinationResolver.lookup():111] Located object with JNDI name [jms/myqueue]<br>
2010-07-01 15:54:47,887 DEBUG [tid=3806,tgn=Pooled Threads] [springframework.jms.support.destination.JndiDestinationResolver.lookup():111] Located object with JNDI name [jms/myqueue]<br>
2010-07-01 15:54:47,949 DEBUG [tid=3806,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.doReceiveAndExecute():311] Received message of type [class weblogic.jms.common.ObjectMessageImpl] from consumer [weblogic.jms.client.WLConsumerImpl@38bae4a] of session [weblogic.jms.client.WLSessionImpl@370ffce]<br>
2010-07-01 15:54:47,965 INFO  [tid=3806,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():132] message received from queue: testmessage1<br>
2010-07-01 15:54:47,965 INFO  [tid=3806,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():137] sleeping<br>
2010-07-01 15:56:52,529 INFO  [tid=3719,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():161] Done processing testmessage1<br>
2010-07-01 15:57:16,763 INFO  [tid=3806,tgn=Pooled Threads] [mycompany.Test.receiveFromQueue():161] Done processing testmessage1<br>
2010-07-01 15:57:24,139 WARN  [tid=3719,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerException():646] Execution of JMS message listener failed<br>
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)<br>
at weblogic.jms.client.JMSSession.commit(JMSSession.java:1200)<br>
at weblogic.jms.client.JMSSession.commit(JMSSession.java:1174)<br>
at weblogic.jms.client.WLSessionImpl.commit(WLSessionImpl.java:108)<br>
at org.springframework.jms.support.JmsUtils.commitIfNecessary(JmsUtils.java:217)<br>
at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:558)<br>
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:465)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)<br>
at java.lang.Thread.run(Thread.java:619)<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)<br>
at weblogic.jms.dispatcher.Request.getResult(Request.java:52)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1124)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59)<br>
... 11 more<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2062)<br>
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2077)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2178)<br>
at weblogic.jms.frontend.FESession.acknowledge(FESession.java:1846)<br>
at weblogic.jms.frontend.FESession.invoke(FESession.java:2923)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)<br>
... 14 more<br>
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA<br>
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)<br>
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:376)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2123)<br>
... 17 more<br>
2010-07-01 15:57:24,139 DEBUG [tid=3719,tgn=Pooled Threads] [org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure():739] Setup of JMS message listener invoker failed - already recovered by other invoker<br>
weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.DispatcherAdapter.convertToJMSExceptionAndThrow(DispatcherAdapter.java:110)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:61)<br>
at weblogic.jms.client.JMSSession.commit(JMSSession.java:1200)<br>
at weblogic.jms.client.JMSSession.commit(JMSSession.java:1174)<br>
at weblogic.jms.client.WLSessionImpl.commit(WLSessionImpl.java:108)<br>
at org.springframework.jms.support.JmsUtils.commitIfNecessary(JmsUtils.java:217)<br>
at org.springframework.jms.listener.AbstractMessageListenerContainer.commitIfNecessary(AbstractMessageListenerContainer.java:558)<br>
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:465)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)<br>
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)<br>
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:881)<br>
at java.lang.Thread.run(Thread.java:619)<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.dispatcher.Request.handleThrowable(Request.java:87)<br>
at weblogic.jms.dispatcher.Request.getResult(Request.java:52)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:1124)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.syncRequest(DispatcherImpl.java:184)<br>
at weblogic.messaging.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.java:287)<br>
at weblogic.jms.dispatcher.DispatcherAdapter.dispatchSyncNoTran(DispatcherAdapter.java:59)<br>
... 11 more<br>
Caused by: weblogic.jms.common.TransactionRolledBackException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA:error resuming transacted session's internal transaction<br>
at weblogic.jms.frontend.FESession.transactedException(FESession.java:2062)<br>
at weblogic.jms.frontend.FESession.throwTransactedException(FESession.java:2077)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2178)<br>
at weblogic.jms.frontend.FESession.acknowledge(FESession.java:1846)<br>
at weblogic.jms.frontend.FESession.invoke(FESession.java:2923)<br>
at weblogic.messaging.dispatcher.Request.wrappedFiniteStateMachine(Request.java:961)<br>
... 14 more<br>
Caused by: javax.transaction.InvalidTransactionException: Attempt to resume an inactive transaction: BEA1-000998DE4AF4FDE2FECA<br>
at weblogic.transaction.internal.TransactionManagerImpl.resume(TransactionManagerImpl.java:360)<br>
at weblogic.transaction.internal.ServerTransactionManagerImpl.resume(ServerTransactionManagerImpl.java:376)<br>
at weblogic.jms.frontend.FESession.transactedInfect(FESession.java:2123)<br>
... 17 more<br>
2010-07-01 15:57:24,154 DEBUG [tid=3937,tgn=Pooled Threads] [springframework.jms.support.destination.JndiDestinationResolver.lookup():111] Located object with JNDI name [jms/myqueue]</p>
<p dir="auto">I know that's a lot of detail, but the general idea is that thread id 3719 picked up the message and then slept.  About a minute into its sleep, the JMS transactions have timed out and another thread (thread id 3806) creates a new JMS session and picks up the same message.  Eventually, both threads get done sleeping and have successfully processed the message and committed to the db.  Thread id 3719 then prints out the exception when it tries to then commit the JMS session b/c its transaction timed out.</p>
<p dir="auto">It appears the root of the problem is the use of the cached JMS session and the lack of periodic commit/rollback on it if no messages are received.  According to the JMS spec, the transaction of a JMS session is started when you create the session, commit it, or roll it back.  The problem is that if no messages are received, Spring JMS is never calling commit or rollback on the shared/cached session (it only does so after a message is processed, in AbstractMessageListenerContainer.doExecuteListener()).  So, if you process a message, then commit/rollback the session, then keep polling to receive messages and keep receiving none, you are using up time in that transaction.  When you do eventually get a message in the receive(), if you're close to being an hour [or whatever your timeout is set to] from when you last received a message with that session, you have very little time to process the message before you will timeout the transaction.  Since XA is not being used, Spring is doing the logical thing of letting your work [and presumably your db transaction commit] before calling commit on the JMS session.  So this consumer will think everything's fine and commit its work, only to find out afterwards that it timed out and someone else did the work too, even though it took well under the transaction timeout to complete its work.</p>
<p dir="auto">There seem to be a number of ways to fix this.  It seems like calling commit or rollback on the shared/cached Session before using its consumer to receive a new message (perhaps in DefaultMessageListenerContainer.invokeListener()) is one way of fixing it, but I'm not sure what other side effects something like this may have (for instance, will calling rollback() on the session cause any client-side cached JMS messages to be returned to the JMS server so that message "pipelining" [as Weblogic calls it] can not be used).</p>
<p dir="auto">Hopefully this makes sense.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.5.6</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398109911" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12581" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12581/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12581">#12581</a> Spring Application getting into hung state while refreshing transacted JMS connection  (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398106931" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12136" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12136/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12136">#12136</a> Setup of JMS message listener invoker failed for destination when upgrading from 3.0.2 to 3.0.4</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398107512" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12215" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12215/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12215">#12215</a> JMS integration with Tibco causes deadlock due to commitIfNecessary in AbstractPollingMessageListenerContainer</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/b456bc107b39ed52efb29fd6540033e9442be1f4/hovercard" href="https://github.com/spring-projects/spring-framework/commit/b456bc107b39ed52efb29fd6540033e9442be1f4"><tt>b456bc1</tt></a></p>