Scope 'session' is not active for the current thread
2012-12-03 14:17
621 查看
1、问题一
用struts2做查询,当不同客户端查询时,a端会看到b端的查询结果,导致原因scope="singleton"
解决方法:
要将bean中的scope设置成“session【session作用域的bean则对每次http Session有效】
<bean id="assetAction" class="com.servicezone.itsd.asset.webapp.action.AssetAction"scope="session"><property name="assetManager" ref="assetManager"/>
<property name="itProductManager" ref="itProductManager"/>
<property name="vendorManager" ref="vendorManager"/>
</bean>”
于是出现如下异常
2、问题二
Struts Problem Report
Struts has detected an unhandled exception:Messages: | 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? 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. Error creating bean with name 'qAction': 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, or processing a request outside of the originally receiving thread? 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. Unable to instantiate Action, qAction, defined for 'qshow' in namespace '/'Error creating bean with name 'qAction': 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, or processing a request outside of the originally receiving thread? 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. |
File: | org/springframework/web/context/request/RequestContextHolder.java |
Line number: | 131 |
Stacktraces
Unable to instantiate Action, qAction, defined for 'qshow' in namespace '/'Error creating bean with name 'qAction':Scope 'session' is not active for the current thread;considerdefining 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, or processing
a request outside of the originally receiving thread? 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.
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399)
解决方法
(1)当使用了Spring's DispatcherServlet以外的Servlet 2.4及以上的Web容器时(如使用JSF或Struts),你需要在Web应用的'web.xml'文件中增加 javax.servlet.ServletRequestListener 定义 <web-app> ... <listener><listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener> ... </web-app>
(2)如果你用的是早期版本的web容器(Servlet 2.4以前的版本),那么你要使用一个javax.servlet.Filter的实现。请看下面的web.xml配置片段: <web-app> .. <filter> <filter-name>requestContextFilter</filter-name> <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class> </filter> <filter-mapping> <filter-name>requestContextFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ... </web-app>
相关文章推荐
- 关于Scope 'session' is not active for the current thread的问题
- org.springframework.beans.factory.BeanCreationException: Scope 'request' is not active for the current thread
- 解决Scope 'request' is not active for the current thread异常
- getCurrentSession()抛出is not valid without active transaction和no session found for current thread异常分析
- Spring报错——Scope 'session' is not active for the current thread
- The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<
- this class is not key value coding-compliant for the key nameField.'
- 错误整理:Unable to add module to the current project as it is not of packaging type 'pom'
- The run destination My Mac 64-bit is not valid for Running the scheme '*'.
- The run destination My Mac 64-bit is not valid for Running the scheme '*****'.
- The run destination My Mac 64-bit is not valid for Running the scheme '*****'.
- The run destination My Mac 64-bit is not valid for Running the scheme '*'
- Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded
- 编译错误“The run destination My Mac 64-bit is not valid for Running the scheme '***',解决办法
- The run destination My Mac 64-bit is not valid for Running the scheme 'MultiTouchDemo'
- 执行 maven 命令 报错Unable to add module to the current project as it is not of packaging type 'pom'
- Trouble shooting:login failed for user 'sa' ,the user is not associated with a trusted SQL Server
- this class is not key value coding-compliant for the key buttonPressed.' 错误解决方式
- 'Operation is not valid due to the current state of the object' error during postback
- Solution: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.