Struts2 and Spring2 with session scoped beans

2008-01-18 Thread Niral Trivedi
Hi All,

We've are trying to use Struts2 with Spring2 on Webspher 6.1 and JDK 1.5.
Basically we are trying to use session scoped beans from Spring
applicationContext in to Struts2 using Spring DI. but running in to issue.
Following are my config files:

web.xml
==
 
struts2
org.apache.struts2.dispatcher.FilterDispatcher



struts2
/*



  
org.springframework.web.context.ContextLoaderListener

==

Spring applicationContext.xml
==


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";>

  
 

  
   
  
 
..
=

When I run this configuration, I am getting following error:
==
[1/18/08 23:49:51:855 EST] 0032 WebAppE   [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()
 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.i

Re: Struts2 and Spring2 with session scoped beans

2008-01-19 Thread Dave Newton
See my reply to your first message.

d.

--- Niral Trivedi <[EMAIL PROTECTED]> wrote:

> Hi All,
> 
> We've are trying to use Struts2 with Spring2 on Webspher 6.1 and JDK 1.5.
> Basically we are trying to use session scoped beans from Spring
> applicationContext in to Struts2 using Spring DI. but running in to issue.
> Following are my config files:
> 
> web.xml
>
==
>  
> struts2
> org.apache.struts2.dispatcher.FilterDispatcher
> 
> 
> 
> struts2
> /*
> 
> 
> 
>   
> org.springframework.web.context.ContextLoaderListener
> 
>
==
> 
> Spring applicationContext.xml
>
==
> 
> 
> 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";>
> 
>   
>  
> 
>   
>
>   
>  
> ..
>
=
> 
> When I run this configuration, I am getting following error:
> ==
> [1/18/08 23:49:51:855 EST] 0032 WebAppE   [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()
>  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(
>