I have web RestClient with struts2 MVC and spring DI and use struts2-spring-plugin to inject after login Authenticated RestClient bean to struts2 Actions in session scope. If I have in web.xml ContextLoaderListener needed for struts2-spring-plugin
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
There is not session scope (my IDE mark session in red) only prototype and singleton are available:
<bean id="restClient" class="com.test.services.RestClient" scope="session">
<constructor-arg ref="dataSource"/>
</bean>
If I have in web.xml RequestContextListener session scope appears
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
but this Exception appears full stacktrace
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?
I know that this problem not exist if I switch to spring MVC but can I use spring bean in session scope with struts2 framework or is there any alternative with struts2 ?