0

我正在编写使用很少工人的 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]

我不知道如何在响应消息返回时接收上下文。

4

1 回答 1

0

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

有问题的代码似乎在CalculateResponseListener.getResultURL().

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

于 2013-07-23T12:17:00.980 回答