Results 1 to 4 of 4

Thread: Scope Session in Spring Framework

  1. #1

    Default 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. #2
    Join Date
    Apr 2006
    Location
    Montreal, Canada
    Posts
    178

    Default

    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

  3. #3

    Default 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

  4. #4
    Join Date
    Dec 2005
    Location
    Philadelphia, PA, USA
    Posts
    228

    Default

    use scope="globalsession"

    See Here
    Thanks
    Dmitry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •