Setup of JMS message listener invoker failed for destination trying to recover

While running integration tests in my application, I get below error messages in the failsafe test report for one of my integration test:

listener.DefaultMessageListenerContainer,WARN,Setup of JMS message listener invoker failed for destination 'jms/myapp.OneWorker' - trying to recover. Cause: Destination [jms/myapp.OneWorker] not found in JNDI; nested exception is javax.naming.NameNotFoundException: jms/myapp.OneWorker

Below is my configuration detail:

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
            <prop key="java.naming.factory.initial">
            <prop key="java.naming.provider.url">vm://localhost:0</prop>
            <prop key="">system</prop>
            <prop key="">system</prop>

<bean id="jndiQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName" value="jmsFactory" />

<bean id="queueConnectionFactory"
    <property name="targetConnectionFactory" ref="jndiQueueConnectionFactory" />
    <property name="sessionCacheSize" value="1" />

<bean id="destinationResolver"
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="cache" value="true" />
    <property name="fallbackToDynamicDestination" value="false" />

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="queueConnectionFactory" />
    <property name="destinationResolver" ref="destinationResolver" />
    <property name="pubSubDomain" value="true" />

<bean id="workerOneListener" class="">
    <property name="workflowManager" ref="workflowManagerImpl" />

<jms:listener-container connection-factory="queueConnectionFactory"
    destination-resolver="destinationResolver" concurrency="3">
    <jms:listener destination="jms/myapp.OneWorker" ref="workerOneListener" />
    <jms:listener destination="jms/myapp.TwoWorker" ref="workerOneListener" />
    <jms:listener destination="jms/myapp.ThreeWorker" ref="workerOneListener" />

The integration tests have a base class which creates the spring application contexts and is shared by all the other integration tests in the module. I enabled logging with debug level and got below error messages:

2014-01-29 11:13:24,connection.CachingConnectionFactory,DEBUG,Closing cached Session:     ActiveMQSession {id=ID:CHN03876623-56121-1390973978321-2:0:70,started=true}
2014-01-29 11:13:24,connection.CachingConnectionFactory,DEBUG,Closing cached Session: ActiveMQSession {id=ID:CHN03876623-56121-1390973978321-2:0:70,started=true}
2014-01-29 11:13:24,connection.CachingConnectionFactory,DEBUG,Creating cached JMS Session for mode 1: ActiveMQSession {id=ID:CHN03876623-56121-1390973978321-2:0:71,started=true}
2014-01-29 11:13:24,jndi.JndiTemplate,DEBUG,Looking up JNDI object with name [jms/myapp.OneWorker]
2014-01-29 11:13:24,destination.JndiDestinationResolver,DEBUG,Destination [jms/myapp.OneWorker] not found in JNDI
javax.naming.NameNotFoundException: jms/myapp.OneWorker
    at org.apache.activemq.jndi.ReadOnlyContext.lookup(
    at javax.naming.InitialContext.lookup(
    at org.springframework.jndi.JndiTemplate$1.doInContext(
    at org.springframework.jndi.JndiTemplate.execute(
    at org.springframework.jndi.JndiTemplate.lookup(
    at org.springframework.jndi.JndiTemplate.lookup(
    at org.springframework.jndi.JndiLocatorSupport.lookup(
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(
    at org.springframework.jms.listener.DefaultMessageListenerContainer$

This log message is repeated again and again infinitely and for the other two workers also. And the build hangs at this point. I use unitils framework for integration testing and create spring context using @SpringApplicationContext in my base integration test class. Where am I going wrong?


Not sure this was the issue, but I solved my problem with this approach:

Using @SpringApplicationContext multiple spring xml files were being loaded and one of the spring xml file which loaded at last has excluded few classes required for the other context xmls and the context was reloaded excluding those classes.

I also saw few spring xmls were repeated in the context file list of @SpringApplicationContext

I removed the redundancies and reordered or removed the unwanted spring xmls or few beans in it. And it worked.

You're trying to do a lookup of a JMS listener which is not present in the JNDI namespace. Are you sure you are running a JNDI container and your MQ server is running and set up correctly?

This happened to me when I wanted to access the same durable subscription (i.e. topic) with the same client ID (ConnectionFactory.setClientId). Assigning unique client IDs to the clients solved the problem.

Need Your Help

How to make "use" attribute (required/optional) depend on another value?

xml xsd schema

I'm trying to do some specific stuff in an XSD XML Schema. I want to set an element as use="required", only if there a specific value to an attribute of another element.

iPhone: IBAction Causes "Unrecognized Selector Sent to Instance" Error

iphone interface-builder selector ibaction

I'm working on my first real iPhone app, a simple To-Do list application to help me organize stuff, except I'm getting an "unrecognized selector sent to instance 0x".