2 qq 28108539 qq_28108539 于 2015.06.05 14:30 提问

spring JMS在接收消息的时候总是报错

org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Unexpected error occured
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:534)
at com.tiantian.springintejms.service.impl.ProducerServiceImpl.sendMessage(ProducerServiceImpl.java:26)
at com.tiantian.springintejms.test.ProducerConsumerTest.testSend(ProducerConsumerTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.jms.JMSException: Unexpected error occured
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1306)
at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1760)
at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:231)
at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:592)
at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:569)
at org.springframework.jms.core.JmsTemplate$3.doInJms(JmsTemplate.java:536)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)
... 26 more
Caused by: java.io.IOException: Unexpected error occured
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:209)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoSuchMethodError: org.slf4j.MDC.getCopyOfContextMap()Ljava/util/Map;
at org.apache.activemq.util.MDCHelper.getCopyOfContextMap(MDCHelper.java:30)
at org.apache.activemq.thread.PooledTaskRunner.(PooledTaskRunner.java:42)
at org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:80)
at org.apache.activemq.ActiveMQSessionExecutor.wakeup(ActiveMQSessionExecutor.java:101)
at org.apache.activemq.ActiveMQSessionExecutor.execute(ActiveMQSessionExecutor.java:85)
at org.apache.activemq.ActiveMQSession.dispatch(ActiveMQSession.java:1535)
at org.apache.activemq.ActiveMQConnection$2.processMessageDispatch(ActiveMQConnection.java:1733)
at org.apache.activemq.command.MessageDispatch.visit(MessageDispatch.java:109)
at org.apache.activemq.ActiveMQConnection.onCommand(ActiveMQConnection.java:1714)
at org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
at org.apache.activemq.transport.TransportFilter.onCommand(TransportFilter.java:69)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
at org.apache.activemq.transport.InactivityMonitor.onCommand(InactivityMonitor.java:227)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:220)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:202)
... 1 more

4个回答

Anteeyou
Anteeyou   2015.06.16 22:22

你好,我是刚刚给你私信的那个,还加你QQ给你发消息了。
我也是跟你一样的配置的,运行后也遇到了同样的问题,经过仔细检查……。
关于这个问题,我已经找到答案了!
原因:我下载的ActiveMQ是apache-activemq-5.11.1版本的,这是目前最新的版本,它在解压后是分成32位和64位两个版本的,
我报的这个错,是因为我运行的是apache-activemq-5.11.1\bin\activemq.bat这个启动程序,而我的系统是win7 64位的,估计是存在兼容问题。
解决:进到apache-activemq-5.11.1\bin\win64目录下,运行这里的activemq.bat程序来启动ActiveMQ服务,就顺利的成功了!
如果你的系统是32位的,你就试下apache-activemq-5.11.1\bin\win32目录下activemq.bat,希望也能帮到你!

u010696144
u010696144   2015.06.05 14:45

如果用的是监听的p2p模式的话,建议你检查一下你的spring配置activemq的配置文件:
检查DefaultMessageListenerContainer这个容器中的属性配置是否对应MessageListenerAdapter,ActiveMQQueue正确(仔细,大写小,丢字母等),
如果这里配置是没问题的话,试着去检查你的链接地址和端口(收消息发消息很可能不在同一网段,造成超时),个人建议,期望收到回复结果

qq_28108539
qq_28108539 我在评论中给你回复了,您能帮我看看嘛
2 年多之前 回复
qq_28108539
qq_28108539   2015.06.05 14:52



<!-- 这个connectionFactory对应的是我们定义的Spring提供的那个ConnectionFactory对象 -->



<!-- 真正可以产生Connection的ConnectionFactory,由对应的 JMS服务厂商提供-->  





<!-- Spring用于管理真正的ConnectionFactory的ConnectionFactory -->  
<bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">  
   <!-- 目标ConnectionFactory对应真实的可以产生JMS Connection的ConnectionFactory -->  
    <property name="targetConnectionFactory" ref="targetConnectionFactory"/>  

<!--这个是队列目的地-->  
<bean id="queueDestination" class="org.apache.activemq.command.ActiveMQQueue">  
    <constructor-arg>  
        <value>SecondQueue</value>  
    </constructor-arg>  
</bean>  
<!-- 消息监听器 -->  



<!-- 消息监听容器 -->

class="org.springframework.jms.listener.DefaultMessageListenerContainer">








我是这样配置的,没有配置默认的Listener,您能看看是这里出现问题了吗

u014542626
u014542626   2015.06.05 17:18

我不太懂,但我看你这里是发送消息报的错吧。ProducerServiceImpl.sendMessage 代码逻辑错误?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!