No thread-bound request found: Are you referring to request attributes outside




Asked on May 04, 2015
What causes the error in my Spring MVC application?


Caused by: 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.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)
at org.springframework.web.context.support.WebApplicationContextUtils.currentRequestAttributes(WebApplicationContextUtils.java:275)
at org.springframework.web.context.support.WebApplicationContextUtils.access$400(WebApplicationContextUtils.java:64)
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:291)
at org.springframework.web.context.support.WebApplicationContextUtils$RequestObjectFactory.getObject(WebApplicationContextUtils.java:286)
at org.springframework.beans.factory.support.AutowireUtils$ObjectFactoryDelegatingInvocationHandler.invoke(AutowireUtils.java:307)
at com.sun.proxy.$Proxy26.setAttribute(Unknown Source)
at org.springframework.web.servlet.theme.CookieThemeResolver.setThemeName(CookieThemeResolver.java:109)
at com.concretepage.config.AppConfiguration.themeResolver(AppConfiguration.java:48)
at com.concretepage.config.AppConfiguration$$EnhancerBySpringCGLIB$$4b590f86.CGLIB$themeResolver$3(<generated>)
at com.concretepage.config.AppConfiguration$$EnhancerBySpringCGLIB$$4b590f86$$FastClassBySpringCGLIB$$dada0aab.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at com.concretepage.config.AppConfiguration$$EnhancerBySpringCGLIB$$4b590f86.themeResolver(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 32 more



Replied on May 04, 2015
It seems that  you are passing HTTPServletRequest in method in wrong class where is no thread bound. Check in the code or post your code so that I can check.


Replied on February 15, 2016
Add RequestContextListener class in web.xml.

If using servlet 3 using annotation, we can add using 

servletContext.addListener(RequestContextListener.class)

in WebApplicationInitializer 


Write Answer











©2024 concretepage.com | Privacy Policy | Contact Us