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

Martin Grigorov commented on WICKET-5487:
-----------------------------------------

Even Spring 4.x does not support this in 4.0.x: 
https://jira.springsource.org/browse/SPR-11305
For 4.1.x they may implement WebSocketSession scope, but this is not the same 
as http request-scoped or session-scoped beans.

> Request-scoped @SpringBean scoped-proxy throws IllegalStateException inside 
> Atmosphere @Subscribe handler method
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-5487
>                 URL: https://issues.apache.org/jira/browse/WICKET-5487
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-atmosphere
>    Affects Versions: 6.13.0
>         Environment: Atmosphere 2.0.7, Tomcat 7.0
>            Reporter: Hendy Irawan
>            Assignee: Emond Papegaaij
>
> Request-scoped {{@SpringBean}}'s work well in plain {{WebPage}}s. Where the 
> bean is powered by a scoped-proxy.
> However, something like this:
> {code}
> import org.apache.wicket.atmosphere.Subscribe;
>       @SpringBean
>       private TenantRef tenant;
>       @Subscribe
>       public void updatePlaceProgress(AjaxRequestTarget target, 
> PlaceProgressGenerated ev) {
>               if (ev.getTenantId().equals(tenant.getTenantId())) {
>                       log.debug("[{}] updating placeProgressTable due to 
> PlaceProgressGenerated {} with {} places",
>                                       tenant.getTenantId(), 
> ev.getGenerationTime(), ev.getPlaceCompletions().size());
>                       target.add(placeProgressTable);
>               }
>       }
> {code}
> will throw:
> {code}
> 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.6.RELEASE.jar:3.2.6.RELEASE]
> at 
> org.soluvas.commons.tenant.RequestOrCommandScope.currentRequestAttributes(RequestOrCommandScope.java:42)
>  ~[classes/:na]
> at 
> org.soluvas.commons.tenant.RequestOrCommandScope.get(RequestOrCommandScope.java:51)
>  ~[classes/:na]
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:330)
>  ~[spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
> at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
>  ~[spring-beans-3.2.6.RELEASE.jar:3.2.6.RELEASE]
> at 
> org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:34)
>  ~[spring-aop-3.2.6.RELEASE.jar:3.2.6.RELEASE]
> at 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
>  ~[spring-aop-3.2.6.RELEASE.jar:3.2.6.RELEASE]
> at com.sun.proxy.$Proxy35.getTenantId(Unknown Source) ~[$Proxy35.class:na]
> at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source) ~[na:na]
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.7.0_25]
> at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
> at 
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:435)
>  ~[wicket-ioc-6.13.0.jar:6.13.0]
> at com.sun.proxy.$Proxy162.getTenantId(Unknown Source) ~[$Proxy162.class:na]
> at 
> com.quikdo.guardian.web.GuardianOverviewPage.updatePlaceProgress(GuardianOverviewPage.java:98)
>  ~[classes/:na]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)(NativeMethodAccessorImpl.java) ~[na:1.7.0_25]
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
> ~[na:1.7.0_25]
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.7.0_25]
> at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
> at com.zeroturnaround.javarebel.uV.invoke(JRebel:1078) ~[na:201312230953]
> at java.lang.reflect.Method.invoke(Method.java) ~[na:1.7.0_25]
> at 
> org.apache.wicket.atmosphere.SubscribeAnnotationEventSubscriptionInvoker.invoke(SubscribeAnnotationEventSubscriptionInvoker.java:43)
>  ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.apache.wicket.atmosphere.AtmosphereRequestHandler.invokeMethod(AtmosphereRequestHandler.java:104)
>  ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.apache.wicket.atmosphere.AtmosphereRequestHandler.executeHandlers(AtmosphereRequestHandler.java:81)
>  ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.apache.wicket.atmosphere.AtmosphereRequestHandler.respond(AtmosphereRequestHandler.java:70)
>  ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
>  ~[wicket-core-6.13.0.jar:6.13.0]
> at 
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
>  ~[wicket-request-6.13.0.jar:6.13.0]
> at 
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) 
> ~[wicket-core-6.13.0.jar:6.13.0]
> at 
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
>  ~[wicket-core-6.13.0.jar:6.13.0]
> at 
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
>  ~[wicket-core-6.13.0.jar:6.13.0]
> at org.apache.wicket.atmosphere.EventBus.post(EventBus.java:372) 
> ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.apache.wicket.atmosphere.EventBus.postToSingleResource(EventBus.java:348) 
> ~[wicket-atmosphere-0.16.jar:0.16]
> at org.apache.wicket.atmosphere.EventBus.post(EventBus.java:323) 
> ~[wicket-atmosphere-0.16.jar:0.16]
> at 
> org.soluvas.web.site.AtmosphereApplication.bridgeToAtmosphere(AtmosphereApplication.java:58)
>  ~[classes/:na]
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)(NativeMethodAccessorImpl.java) ~[na:1.7.0_25]
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
> ~[na:1.7.0_25]
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.7.0_25]
> at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
> at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) 
> ~[guava-15.0.jar:na]
> at 
> com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
>  ~[guava-15.0.jar:na]
> at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 
> ~[guava-15.0.jar:na]
> at com.google.common.eventbus.AsyncEventBus.access$001(AsyncEventBus.java:34) 
> ~[guava-15.0.jar:na]
> at com.google.common.eventbus.AsyncEventBus$1.run(AsyncEventBus.java:100) 
> ~[guava-15.0.jar:na]
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  ~[na:1.7.0_25]
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  ~[na:1.7.0_25]
> at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
> {code}
> It's understandable because the original web request had already been gone at 
> the time the {{@Subscribe}} triggered.
> However, if this works as intended, what is the proper way to access beans 
> "as it was during the original request"?



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to