You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2013/12/05 13:35:37 UTC

[jira] [Comment Edited] (CXF-5431) Spring Request scope is not available in OneWay WS method.

    [ https://issues.apache.org/jira/browse/CXF-5431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13840051#comment-13840051 ] 

Sergey Beryozkin edited comment on CXF-5431 at 12/5/13 12:34 PM:
-----------------------------------------------------------------

I wonder if you should actually get Spring postponing the creation of request-scoped service beans till the moment the service is actually invoked ? If it is created before a thread context is switched then there is nothing that technically be done because Spring will record the original thread ?

JAXWS invoker accepts a Factory wrapper, so may be a custom invoker can do it




was (Author: sergey_beryozkin):
I wonder if you should actually get Spring postponing the creation of request-scoped service beans till the moment the service is actually invoked ? If it is created before a thread context is switched then there is nothing that technically be done because Spring will record the original thread ?



> 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)