spring 对于尝试恢复的目标,JMS 消息侦听器调用程序的设置失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21423643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setup of JMS message listener invoker failed for destination trying to recover
提问by EmeraldTablet
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:
集成测试有一个基类,它创建 spring 应用程序上下文,并由模块中的所有其他集成测试共享。
我启用了调试级别的日志记录并收到以下错误消息:
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.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?
这条日志消息被无限重复一次又一次地重复,其他两个工人也是如此。此时构建挂起。我使用unitils
框架进行集成测试并@SpringApplicationContext
在我的基本集成测试类中使用创建 spring 上下文。我哪里错了?
采纳答案by EmeraldTablet
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.
使用@SpringApplicationContext
多个 spring xml 文件正在加载,最后加载的 spring xml 文件之一排除了其他上下文 xml 所需的几个类,并且重新加载了不包括这些类的上下文。
I also saw few spring xmls were repeated in the context file list of @SpringApplicationContext
我还看到在上下文文件列表中重复了很少的 spring xml @SpringApplicationContext
I removed the redundancies and reordered or removed the unwanted spring xmls or few beans in it. And it worked.
我删除了冗余并重新排序或删除了不需要的 spring xmls 或其中的一些 bean。它奏效了。
回答by Gábor Paller
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.
当我想使用相同的客户端 ID (ConnectionFactory.setClientId) 访问相同的持久订阅(即主题)时,这发生在我身上。为客户端分配唯一的客户端 ID 解决了这个问题。
回答by Kurt Du Bois
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?
您正在尝试查找 JNDI 名称空间中不存在的 JMS 侦听器。您确定您正在运行 JNDI 容器并且您的 MQ 服务器正在正确运行和设置吗?