Announcement Announcement Module
Collapse
No announcement yet.
Scope Session in Spring Framework Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scope Session in Spring Framework

    Hi All,

    I am using spring 2.0 and in my application i wanted to test the scope of session for the same. For that I have given scope="session" in applicationcontext.xml but while running the app I am getting error.

    aused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'HibernateBean': 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? 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.Abstract BeanFactory.getBean(AbstractBeanFactory.java:304)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:733)
    at org.springframework.web.jsf.DelegatingVariableReso lver.resolveVariable(DelegatingVariableResolver.ja va:122)
    at org.apache.myfaces.el.ValueBindingImpl$ELVariableR esolver.resolveVariable(ValueBindingImpl.java:570)
    at org.apache.commons.el.NamedValue.evaluate(NamedVal ue.java:124)
    at org.apache.commons.el.ComplexValue.evaluate(Comple xValue.java:140)
    at org.apache.myfaces.el.ValueBindingImpl.getValue(Va lueBindingImpl.java:386)
    ... 294 more
    Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? 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.RequestCon textHolder.currentRequestAttributes(RequestContext Holder.java:102)
    at org.springframework.web.context.request.SessionSco pe.get(SessionScope.java:88)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:285)
    ... 301 more

    If someone can help me out that would be the greate help

    Thanks in advance.

  • #2
    The exception message is quite clear, you need to register the RequestContextListener in your web.xml file:

    Code:
    <listener>
    	<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>
    Cheers,
    GB

    Comment


    • #3
      Session scope problem

      Hello spiff,

      Thanks but I have already defined RequestContextListener in web.xml. The application is portal application that is running on JBossPortal Application Server. If you have any other solution please let me know.

      Thanks
      Ateet

      Comment


      • #4
        use scope="globalsession"

        See Here

        Comment

        Working...
        X