Hi all,

Got a problem with Sping JMS whereby the listener does not ever seem to be called. I've been using Spring for some time, but this is the first attempt at using it with JMS.

We are using Spring 2.0.2, Weblogic 8.1 sp4. (Using the JMS 1.0.2 methods in Spring as that's what our version of weblogic supports).

There are two parts to what we're doing. One class adds messages to a queue, whilst another is to processes the received messages from the same queue.

The code that adds a message to the queue works sucessfully, but the listener doesn't ever seem to read the message. I temporarily created a regular MDB, and it read the messages that were added fine, so it appears to be an issue with my listener code and/or configuration.

When the application first starts up, there are some exceptions thrown trying to create the listener. In the end though, it seems to refresh the JMS connection, and ends with a 'blocking' message as shown below. I'm not sure if this means the listener is OK or not.

01-31-2007 09:13:03.717 org.springframework.jms.listener.DefaultMessageLis tenerContainer102 Initiating transaction rollback on application exception
java.lang.ClassCastException
at org.springframework.jms.connection.ConnectionFacto ryUtils.doGetTransactionalSession(ConnectionFactor yUtils.java:208)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer.doReceiveAndExecute(DefaultMessageL istenerContainer.java:516)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer.receiveAndExecute(DefaultMessageLis tenerContainer.java:474)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(DefaultMessageListenerContainer.java:904)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.run(Def aultMessageListenerContainer.java:857)
at org.springframework.core.task.SimpleAsyncTaskExecu tor$ConcurrencyThrottlingRunnable.run(SimpleAsyncT askExecutor.java:203)
at java.lang.Thread.run(Thread.java:534)
01-31-2007 09:13:03.717 org.springframework.jms.connection.JmsTransactionM anager102 Initiating transaction rollback
01-31-2007 09:13:03.732 org.springframework.transaction.support.Transactio nSynchronizationManager Removed value [org.springframework.jms.connection.ConnectionHolde r@4dd014] for key [weblogic.jms.client.JMSXAConnectionFactory@1fc9f88] from thread [listenerContainer-1]
01-31-2007 09:13:03.763 org.springframework.beans.factory.support.DefaultL istableBeanFactory Invoking BeanPostProcessors after initialization of bean 'productFactoryService'
01-31-2007 09:13:03.763 org.springframework.beans.factory.support.DefaultL istableBeanFactory Calling code asked for FactoryBean instance for name 'productFactoryService'
01-31-2007 09:13:03.763 org.springframework.beans.factory.support.DefaultL istableBeanFactory Returning cached instance of singleton bean 'productFactoryService'
01-31-2007 09:13:03.763 org.springframework.beans.factory.support.DefaultL istableBeanFactory Bean with name 'productFactoryService' is a factory bean
01-31-2007 09:13:03.810 org.springframework.context.support.FileSystemXmlA pplicationContext Publishing event in context [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=4205299]: org.springframework.context.event.ContextRefreshed Event[source=org.springframework.context.support.FileSys temXmlApplicationContext: display name [org.springframework.context.support.FileSystemXmlA pplicationContext;hashCode=4205299]; startup date [Wed Jan 31 09:12:55 WST 2007]; root of context hierarchy]
01-31-2007 09:13:03.810 org.springframework.beans.factory.support.DefaultL istableBeanFactory Returning cached instance of singleton bean 'productFactoryService'
01-31-2007 09:13:03.810 org.springframework.beans.factory.support.DefaultL istableBeanFactory Bean with name 'productFactoryService' is a factory bean
01-31-2007 09:13:03.857 org.springframework.transaction.interceptor.Transa ctionInterceptor Getting transaction for au.gov.wa.dola.enterprise.businesszone.service.pro ductfactory.service.ProductFactoryService.submitJo b
01-31-2007 09:13:03.857 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Using transaction object [org.springframework.transaction.jta.JtaTransaction Object@10cc9b4]
01-31-2007 09:13:03.857 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Creating new transaction with name [au.gov.wa.dola.enterprise.businesszone.service.pro ductfactory.service.ProductFactoryService.submitJo b]
01-31-2007 09:13:03.888 org.springframework.transaction.support.Transactio nSynchronizationManager Initializing transaction synchronization
01-31-2007 09:13:08.735 org.springframework.jms.listener.DefaultMessageLis tenerContainer102 Setup of JMS message listener invoker failed - trying to recover
java.lang.ClassCastException
at org.springframework.jms.connection.ConnectionFacto ryUtils.doGetTransactionalSession(ConnectionFactor yUtils.java:208)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer.doReceiveAndExecute(DefaultMessageL istenerContainer.java:516)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer.receiveAndExecute(DefaultMessageLis tenerContainer.java:474)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.invokeL istener(DefaultMessageListenerContainer.java:904)
at org.springframework.jms.listener.DefaultMessageLis tenerContainer$AsyncMessageListenerInvoker.run(Def aultMessageListenerContainer.java:857)
at org.springframework.core.task.SimpleAsyncTaskExecu tor$ConcurrencyThrottlingRunnable.run(SimpleAsyncT askExecutor.java:203)
at java.lang.Thread.run(Thread.java:534)
01-31-2007 09:13:08.735 org.springframework.jms.listener.DefaultMessageLis tenerContainer102 Successfully refreshed JMS Connection
01-31-2007 09:13:08.735 org.springframework.core.task.SimpleAsyncTaskExecu tor Concurrency count 1 has reached limit 1 - blocking



When the message is sent, the folowing logging is output:

01-31-2007 09:13:10.621 org.springframework.jms.core.JmsTemplate102 Executing callback on JMS Session [connection455.session456] from connection [connection455]
01-31-2007 09:13:10.793 org.springframework.jms.core.JmsTemplate102 Sending created message [ObjectMessage[null,[JobRequest: productId=1111 requestDetail= 0211000040 ]]]
01-31-2007 09:13:10.886 org.springframework.transaction.interceptor.Transa ctionInterceptor Invoking commit for transaction on au.gov.wa.dola.enterprise.businesszone.service.pro ductfactory.service.ProductFactoryService.submitJo b
01-31-2007 09:13:10.886 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Triggering beforeCommit synchronization
01-31-2007 09:13:10.886 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Triggering beforeCompletion synchronization
01-31-2007 09:13:10.886 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Initiating transaction commit
01-31-2007 09:13:11.307 org.springframework.transaction.jta.WebLogicJtaTra nsactionManager Triggering afterCompletion synchronization
01-31-2007 09:13:11.307 org.springframework.transaction.support.Transactio nSynchronizationManager Clearing transaction synchronization



No logging ever appears to indicate that the listener has picked anything up.

The relevant Spring config is shown below:

<bean id="jmsConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="weblogic.jws.jms.dliQueueConnectionFactory" />
</bean>

<bean id="jmsQueueTemplate"
class="org.springframework.jms.core.JmsTemplate102 ">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="pubSubDomain" value="false" />
</bean>

<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTrans actionManager102">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

<bean id="productFactoryQueueDestination"
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="jms.productFactoryQueue" />
</bean>

<bean id="productFactoryQueueConsumer" class="au.gov.wa.dola.enterprise.businesszone.serv ice.productfactory.queue.ProductFactoryQueueConsum er">
</bean>

<bean id="listenerContainer"
class="org.springframework.jms.listener.DefaultMes sageListenerContainer102">
<property name="concurrentConsumers" value="1" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="destination" ref="productFactoryQueueDestination" />
<property name="messageListener" ref="productFactoryQueueConsumer" />
<property name="pubSubDomain" value="false" />
</bean>



The basic message consumer code is shown below - just basic test code for now:

public class ProductFactoryQueueConsumer implements MessageListener {

public void onMessage(Message aMessage) {

ObjectMessage objectMessage = (ObjectMessage) aMessage;
System.out.println(objectMessage.toString());
}
}


Any help would be very much appreciated.

John