Announcement Announcement Module
Collapse
No announcement yet.
Request scoped beans accessed from servlet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Request scoped beans accessed from servlet

    Hi,
    I am having trouble accessing my beans (request scoped) from my servlet. What is the correct listener that I should use in my web.xml? thank you! Here's the error message.

    Code:
    SEVERE: StandardWrapper.Throwable
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyDoer': Scope 'request' 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.
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:342)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
    	at com.base.ObjectFactory.getObject(ObjectFactory.java:20)
    	at com.servlet.MaintenanceServlet.setVariables(MaintenanceServlet.java:493)
    	at com.servlet.MaintenanceServlet.init(MaintenanceServlet.java:488)
    	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
    	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Please help. Thank you!

  • #2
    The answer is given in the stacktrace...

    Code:
     use RequestContextListener or RequestContextFilter to expose the current request
    Use either...

    Comment

    Working...
    X