Hi All, I am using RAD7.0, JDK 1.5, Struts2 and Spring 2.x. We have been using Struts1.x and Spring 1.x for a long time now and moving our app to Struts2 + Spring2
We are trying to have Spring manage all the value objects and action objects. And so followed steps in Struts document to add struts2-spring plugin jar and made necessary changes but getting errors when try to create a bean in session scope. Following are my configuration files: web.xml ================================================================================================================================================== ......................... <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener</listener-class> </listener> ........ ========================================================================================================= Spring applicationContext.xml ============================================================================ <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> ........ <bean id="mVO" class="com.foo.bar.vo.MyVO" scope="session"> <aop:scoped-proxy/> </bean> <bean id="myInterceptor" class="com.foo.bar.interceptors.MyInterceptor"> <property name="mvo"> <ref local="mVO" /> </property> </bean> ....... ======================================================================================================= With this configuration, server starts up correct without any issues, but when I try to access my action class, I am getting following error: ===================================================================================================== [1/18/08 23:49:51:855 EST] 00000032 WebApp E [Servlet Error]-[Error creating bean with name 'scopedTarget.mVO': 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? 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.]: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.mVO': 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? 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. Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? 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:102) at org.springframework.web.context.request.SessionScope.get( SessionScope.java:88) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:283) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:160) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget( SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.getTarget (Cglib2AopProxy.java:660) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept (Cglib2AopProxy.java:610) at com.foo.bar.vo.MyVO$$EnhancerByCGLIB$$d821bb7e.setClassName (<generated>) at com.foo.bar.interceptors.MyInterceptor.intercept(MyInterceptor.java :56) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:224) at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling( DefaultActionInvocation.java:223) at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile( UtilTimerStack.java:455) at com.opensymphony.xwork2.DefaultActionInvocation.invoke( DefaultActionInvocation.java:221) at org.apache.struts2.impl.StrutsActionProxy.execute( StrutsActionProxy.java:50) at org.apache.struts2.dispatcher.Dispatcher.serviceAction( Dispatcher.java:504) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter( FilterDispatcher.java:419) at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter( FilterInstanceWrapper.java:190) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter( WebAppFilterChain.java:130) at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter( WebAppFilterChain.java:87) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter( WebAppFilterManager.java:701) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter( WebAppFilterManager.java:646) at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters( DefaultExtensionProcessor.java:628) at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.invokeFilters( DefaultExtensionProcessor.java:145) at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest( DefaultExtensionProcessor.java:595) at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest( DefaultExtensionProcessor.java:111) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java :238) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java :811) at com.ibm.ws.wswebcontainer.WebContainer.handleRequest( WebContainer.java:1433) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready( WCChannelLink.java:93) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination( HttpInboundLink.java:465) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation( HttpInboundLink.java:394) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete( HttpICLReadCallback.java:102) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted (AioReadCompletionListener.java:152) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback( AbstractAsyncFuture.java:213) at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions( AbstractAsyncFuture.java:195) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194) at com.ibm.io.async.ResultHandler.runEventProcessingLoop( ResultHandler.java:741) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510) =========================================================================================================== So, I tried changing web.xml and replace org.springframework.web.context.ContextLoaderListener with org.springframework.web.context.request.RequestContextListener. At that point, server starts up correctly, but while accessing action class, I am getting error message saying : [1/19/08 0:54:47:605 EST] 00000032 StrutsSpringO E org.apache.commons.logging.impl.Jdk14Logger fatal ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ********** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: <listener> <listener-class> org.springframework.web.context.ContextLoaderListener</listener-class> </listener> It looks like, Struts2 only works with ContextLoaderListener, but Spring2 requires to use RequestContextListener if you are using session/request scoped bean in Servlet 2.4+. I tried to search on mailing archive but didn't find any solution. Can somebody please help if they have tried implementing session/request scoped beans using Spring2 with Struts2? Thanks a bunch in advance.