I have searched a lot on forum and its very common issue. But somehow i 'm not able to resolve despite putting too much time. Prbably missing something silly. Please note that it is a Portlet application deployed on Jetspeed 2.
I have a session scope bean defined in spring context and injectd in other other spring beans. It gives error that:
My context file looks like:Code:Error creating bean with name 'myBusinessDelegate': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.sessionUserInfo': 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.
Delegate class is:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <tx:annotation-driven /> <bean id="loggerListener" class="org.springframework.security.event.authentication.LoggerListener" /> <bean id="sessionUserInfo" class="com.my.package.SessionUserInfo" scope="session"> <aop:scoped-proxy/> </bean> <context:component-scan base-package="com.root"/>
and web.xml is:Code:@Component public class MyDelegate { private static final Logger logger=Logger.getLogger(MyDelegate.class); private SessionUserInfo sessionUserInfo; public MyDelegate(){ } @Autowired public void setSessionUserInfo(SessionUserInfo sessionUserInfo) { this.sessionUserInfo = sessionUserInfo; System.out.println(sessionUserInfo.getUserName()); }
Code:<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>emr</display-name> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <listener> <listener-class>com.my.package.AppContextListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j-myapp.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext*.xml</param-value> </context-param> <context-param> <param-name>webAppRootKey</param-name> <param-value>myapp-root</param-value> </context-param> <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> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>


Reply With Quote