Spring3“会话”范围和 IllegalStateException 甚至已经定义了代理和 RequestCntextListerner
我在 Websphere 7 中部署时遇到此错误。但在 Tomcat 7 中工作正常。这是一种奇怪的行为。
无法实例化 Action,...:范围“会话”对于当前线程不活动;考虑为此 bean 定义一个作用域代理...在这种情况下,请使用
RequestContextListener
或RequestContextFilter
公开当前请求。
我使用Spring 3 + Struts2使用注解配置 这是我的配置:
操作配置:
@Bean
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
public sws.web.utilization.reports.Action public_utilization_reports(){
sws.web.utilization.reports.Action action = new sws.web.utilization.reports.Action();
return action;
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>sws-web</display-name>
<!-- ============================================================================== -->
<!-- Spring Configuration parameters -->
<!-- ============================================================================== -->
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
sws.domain.config.SWSDomainConfig,
sws.web.config.ActionsConfig
</param-value>
</context-param>
<!-- ============================================================================== -->
<!-- Filters -->
<!-- ============================================================================== -->
<filter>
<filter-name>ResponseOverrideFilter</filter-name>
<filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>
<filter>
<filter-name>HibernateSessionConversationFilter</filter-name>
<filter-class>pnd.core.web.filter.HibernateSessionConversationFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>hibernateSessionFactory</param-value>
</init-param>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HibernateSessionConversationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ============================================================================== -->
<!-- Listeners -->
<!-- ============================================================================== -->
<!-- Spring Listener -->
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!--Support the scoping of beans at the request, session, and global session levels (web-scoped beans) -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Struts Tiles Listener -->
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
请帮忙。提前致谢
I've got this error when deploying in Websphere 7. but it's working fine in Tomcat 7. It's such a strange behavior.
Unable to instantiate Action, ...: Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean.... In this case, use
RequestContextListener
orRequestContextFilter
to expose the current request.
I use Spring 3 + Struts2 using annotation configuration
Here is my configurations:
Action configuration:
@Bean
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
public sws.web.utilization.reports.Action public_utilization_reports(){
sws.web.utilization.reports.Action action = new sws.web.utilization.reports.Action();
return action;
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>sws-web</display-name>
<!-- ============================================================================== -->
<!-- Spring Configuration parameters -->
<!-- ============================================================================== -->
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
sws.domain.config.SWSDomainConfig,
sws.web.config.ActionsConfig
</param-value>
</context-param>
<!-- ============================================================================== -->
<!-- Filters -->
<!-- ============================================================================== -->
<filter>
<filter-name>ResponseOverrideFilter</filter-name>
<filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>
<filter>
<filter-name>HibernateSessionConversationFilter</filter-name>
<filter-class>pnd.core.web.filter.HibernateSessionConversationFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>hibernateSessionFactory</param-value>
</init-param>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HibernateSessionConversationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ResponseOverrideFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ============================================================================== -->
<!-- Listeners -->
<!-- ============================================================================== -->
<!-- Spring Listener -->
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!--Support the scoping of beans at the request, session, and global session levels (web-scoped beans) -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Struts Tiles Listener -->
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Please help. Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)