Question

In application context when i have

    <beans:bean id="Facade"
      class="com.facade.Facade"/> 

every thing works fine i can access facade using SpringUtil.getBean("Facade")

but if i add session = scope i.e

<beans:bean id="Facade"
      class="com.facade.Facade" scope="session"/>

i get the below error.... How to fix it ? I am using zk + spring security

     [java] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'F
acade': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you inte
nd 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 req
uest and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In thi
s case, use RequestContextListener or RequestContextFilter to expose the current request.
Was it helpful?

Solution

Your comment is indeed correct for the solution. But why do you want a facade to be in the session scope?

With other words you will create this bean again and again for each session that you have. So if 5 users log in you have 5 beans of the same class.
Is that still the wanted situation?

Greetz chill.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top