[
https://issues.apache.org/jira/browse/CXF-5431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13840176#comment-13840176
]
Daniel Kulp commented on CXF-5431:
----------------------------------
Michael,
This is a case where spring request scope processing and Web Services specs
requirements clash. With one-ways and WS-Addressing use cases, we are
supposed to send back the 202 accepted as quickly as possible so the client
making the call can continue. Many of the servlet engines won't allow us to
send that until the the stack unwinds from the servlet. Thus, we HAVE to flip
to another thread to meet the spec requirements. This is particularly
important with decoupled ws-addressing as if we don't, the client will likely
receive the real response before even getting the 202. If the clients are not
designed to handle that (and I'm not even sure CXF is), that can cause some
strange deadlocks.
Basically, this is a case where the specs that CXF implements doesn't mesh well
with Spring. In these scenarios, the spec correctness is our priority and we
provide switches/flags to allow the user to turn off that behavior.
> Spring Request scope is not available in OneWay WS method.
> ----------------------------------------------------------
>
> Key: CXF-5431
> URL: https://issues.apache.org/jira/browse/CXF-5431
> Project: CXF
> Issue Type: Bug
> Components: JAX-WS Runtime
> Affects Versions: 2.7.8, 2.6.11
> Reporter: Michael Zav'yalov
> Attachments: testing-project.zip
>
>
> Have an asynchronous WEB operation (without any output of fault messages).
> This operation is anotated as @OneWay in the generated code (WS interface).
> The WS is configurated as a Spring bean. The bean uses another Spring bean
> that is declared with scope="request" and aop:scoped-proxy.
> When the WS operation is processed - calling the WS implementation is
> scheduled in a background queue (WorkQueueManager ?). When it really executed
> - the following exception is raised:
> [#|2013-12-02T13:02:23.201+0200|WARNING|glassfish3.1.2|org.apache.cxf.phase.PhaseInterceptorChain|_ThreadID=40;_ThreadName=Thread-2;|Application
>
> {http://testing.cxf.apache.org/}OneWayWebServiceService#{http://testing.cxf.apache.org/}OneWayOperation
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Error creating bean with name
> 'scopedTarget.requestScopeBean': Scope 'request' is not active for the
> current thread; consider defining a scoped proxy for this bean if you intend
> to refer to it from a singleton; nested exception is
> 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.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162)
> at
> org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:213)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128)
> at
> org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
> at
> org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:68)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
> at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at
> org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
> at
> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.resume(PhaseInterceptorChain.java:242)
> at
> org.apache.cxf.interceptor.OneWayProcessorInterceptor$1.run(OneWayProcessorInterceptor.java:144)
> at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
> at
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'scopedTarget.requestScopeBean': Scope 'request' is
> not active for the current thread; consider defining a scoped proxy for this
> bean if you intend to refer to it from a singleton; nested exception is
> 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.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:343)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
> at
> org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:34)
> at
> org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.getTarget(CglibAopProxy.java:663)
> at
> org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:614)
> at
> org.apache.cxf.testing.RequestScopeBean$$EnhancerByCGLIB$$cd84f255.doSomething(<generated>)
> at
> org.apache.cxf.testing.OneWayWebService.oneWayOperation(OneWayWebService.java:23)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
> at
> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
> ... 17 more
> Caused by: 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)
> at
> org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:40)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:329)
> ... 29 more
> |#]
> I can provide the simplest maven project to reproduce the problem.
--
This message was sent by Atlassian JIRA
(v6.1#6144)