春天,jms失去了背景

时间:2013-07-23 06:34:02

标签: spring spring-mvc jms activemq spring-jms

我正在编写使用很少工人的webapp。我决定使用JMS ActiveMQ来进行通信。我的问题是,当我将工作者配置更改为java时(当配置在xml中时我无法运行jar)我在消息返回webapp时遇到问题:

2013-07-19 21:23:23.653   [org.springframework.jms.listener.DefaultMessageListenerContainer#4-3] WARN  o.s.j.l.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.support.WebApplicationContextUtils.currentRequestAttributes(WebApplicationContextUtils.java:281) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.support.WebApplicationContextUtils.access$300(WebApplicationContextUtils.java:69) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:296) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:292) ~[spring-web-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler.invoke(AutowireUtils.java:179) ~[spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at com.sun.proxy.$Proxy52.getScheme(Unknown Source) ~[na:na]
at pl.optymalnetrasy.jms_calculate.CalculateResponseListener.getResultURL(CalculateResponseListener.java:144) ~[CalculateResponseListener.class:na]
at pl.optymalnetrasy.jms_calculate.CalculateResponseListener.onMessage(CalculateResponseListener.java:73) ~[CalculateResponseListener.class:na]
at org.springframework.jms.listener.adapter.MessageListenerAdapter.onMessage(MessageListenerAdapter.java:330) ~[spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:537) ~[spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:497) ~[spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) ~[spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) [spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) [spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1096) [spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at     org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1088) [spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:985) [spring-jms-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_21]

我不知道在回复消息回来时如何接收上下文。

1 个答案:

答案 0 :(得分:0)

您正在尝试从JMS线程访问Web资源,但这是不允许的。

违规代码似乎在CalculateResponseListener.getResultURL()

您需要重新设计应用程序以避免这种情况。