struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wild_oscar <>
Subject Re: Using Spring proxied Session Beans with the ExecAndWaitInterceptor
Date Mon, 14 May 2012 18:03:34 GMT

I've got the exact same problem as this user. Injecting either request or
session scoped beans in an interceptor yields the error
"org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'scopedTarget.diagnosticContext': Scope 'session' 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;..."

My setup is fairly similar to the Roger's. Injecting the same request scoped
bean onto an action works as expected, so the problem is not in the
configuration (the ContextLoaderListener and RequestContextListener are
defined in the web.xml).

Do you know how to inject the beans onto the interceptor (which is also
being managed through Spring)?


Miguel Almeida

roger wrote
> Hi
> I've been experimenting with using Springs scoped Proxy beans to handle my
> session bean management rather than using the more normal SessionAware
> interface, 
> <bean id = "diagnosticContext"
> class=""
> 			scope="session">
> 			<aop:scoped-proxy/>
> 			</bean>
> and injecting my session beans into the application where required. Up
> until now it's been working well. However, I've hit a problem with trying
> to access the session in an action that runs under the
> ExecAndWaitInterceptor and the action crashes with;
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'scopedTarget.diagnosticContext': Scope 'session' 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. 
> I have the RequestContextListener configured in my web-xml and the action
> that runs under the ExecAndWaitInterceptor is created through Spring using
> the @Controller annotation with @Scope("prototype"). I'm guessing that the
> problem is that the ExecAndWait interceptor creates it's own thread under
> which the action runs, so when it accesses the proxy bean, the proxy bean
> cannot see the "session"
> I can't use SessionAware here as the Spring documentation specifically
> states that Spring stores the session beans in a location that is tied to
> the session object - not that it stores the beans actually in the session
> object itself - so I'm not sure that I would be able to access the spring
> proxy bean reliably.
> While trying to find out more, I came across references in the 2.0 and 2.1
> documentation to the SessionContextAutowiringInterceptor which by it's
> name seems a likely thing to investigate, but this isn't in Struts 2.2.1
> anymore - was it redundant or has the functionality moved into another
> interceptor?
> Has anyone managed to get Spring proxied session beans working with the
> ExecAndWaitInterceptor?

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message