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">
<props>
<prop key="java.naming.factory.initial">
org.apache.activemq.jndi.ActiveMQInitialContextFactory</prop>
<prop key="java.naming.provider.url">vm://localhost:0</prop>
<prop key="java.naming.security.principal">system</prop>
<prop key="java.naming.security.credentials">system</prop>
</props>
</property>
</bean>
<bean id="jndiQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="jmsFactory" />
</bean>
<bean id="queueConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="jndiQueueConnectionFactory" />
<property name="sessionCacheSize" value="1" />
</bean>
<bean id="destinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="cache" value="true" />
<property name="fallbackToDynamicDestination" value="false" />
</bean>
<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>
<bean id="workerOneListener" class="com.org.myapp.workflow.WorkerOne">
<property name="workflowManager" ref="workflowManagerImpl" />
</bean>
<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" />
</jms:listener-container>
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(ReadOnlyContext.java:225)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:179)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jms.support.destination.JndiDestinationResolver.resolveDestinationName(JndiDestinationResolver.java:111)
at org.springframework.jms.support.destination.JmsDestinationAccessor.resolveDestinationName(JmsDestinationAccessor.java:100)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.createListenerConsumer(AbstractPollingMessageListenerContainer.java:221)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.initResourcesIfNecessary(DefaultMessageListenerContainer.java:1081)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
at java.lang.Thread.run(Thread.java:662)
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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With