WebSphere6.x中不能使用Spring的session scope注入对象的解决办


原来一直使用spring的aop去注入一些Session scope的对象,但是今天在部署此类应用程序的时候却出现了以下异常:
[09-12-25 14:50:52:562 CST] 0000003f WebApp        E   SRVE0026E: [Servlet ERROR]-[Filter [IdentityFilter]: filter is unavailable.]:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.sessionUser': 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:285)
    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:661)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:611)
    at com.interprosoft.maximo.maximostudy.user.module.User$$EnhancerByCGLIB$$64b912.toString(<generated>)
    at java.lang.String.valueOf(String.java(Inlined Compiled Code))
    at java.lang.StringBuffer.append(StringBuffer.java(Compiled Code))
    ...
查了半天资料,也没有人给出解决办法,没办法了,有把spring的文档找来看看了,最后把web.xml文件中使用的Listener换成Filter就把问题解决了,就是把

改成


但是具体原因还是没有搞清楚,等以后有时间再好好看看。

 

posted @ 2009-12-26 19:27  程序员天下  阅读(297)  评论(0编辑  收藏  举报