aspose file tools*
The moose likes Spring and the fly likes Spring session= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring session="scope"" Watch "Spring session="scope"" New topic
Author

Spring session="scope"

samuel john
Greenhorn

Joined: Aug 14, 2011
Posts: 3
Hi All,

am new to Spring framework, we are working on a project using Spring+BlazeDS+Flex.
So far integration with flex went through with out any issues.

We tried to use HttpSession to maintain userPreferences and found this link where by setting scope="session" will sort our needs.

but unfortunately we are facing below exception:

20:44:44,818 ERROR [STDERR] java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
20:44:44,819 ERROR [STDERR] at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
20:44:44,819 ERROR [STDERR] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
20:44:44,819 ERROR [STDERR] at com.lynx.saw.spring.global.dao.GlobalLoggedIn.isLoggedIn(GlobalLoggedIn.java:43)
20:44:44,819 ERROR [STDERR] at com.lynx.saw.spring.login.dao.LoginDAO.createMenu(LoginDAO.java:157)
20:44:44,819 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20:44:44,819 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
20:44:44,820 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
20:44:44,820 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
20:44:44,820 ERROR [STDERR] at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
20:44:44,820 ERROR [STDERR] at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
20:44:44,826 ERROR [STDERR] at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1503)
20:44:44,826 ERROR [STDERR] at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:884)
20:44:44,826 ERROR [STDERR] at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
20:44:44,826 ERROR [STDERR] at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
20:44:44,826 ERROR [STDERR] at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
20:44:44,826 ERROR [STDERR] at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
20:44:44,827 ERROR [STDERR] at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
20:44:44,827 ERROR [STDERR] at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
20:44:44,827 ERROR [STDERR] at org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter.handle(MessageBrokerHandlerAdapter.java:79)
20:44:44,827 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
20:44:44,827 ERROR [STDERR] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
20:44:44,827 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
20:44:44,828 ERROR [STDERR] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
20:44:44,828 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
20:44:44,828 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
20:44:44,828 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
20:44:44,828 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
20:44:44,828 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
20:44:44,828 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
20:44:44,829 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
20:44:44,829 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
20:44:44,829 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
20:44:44,829 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
20:44:44,830 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
20:44:44,830 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
20:44:44,830 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
20:44:44,830 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)


Below code is generating the exception:


Part of web-application-config.xml :




Kindly correct me if at all am doing some thing wrong.


Thanks
Sam
samuel john
Greenhorn

Joined: Aug 14, 2011
Posts: 3
Hi All,

Have tried changing this in my applicationContext files as


But the user Object returned in class GlobalLoggedIn is NULL. Kindly correct me if at all am missing any thing

Thanks again
Sam
samuel john
Greenhorn

Joined: Aug 14, 2011
Posts: 3
Sorry all, just noticed have posted title wrongly as session="scope" instead of scope="session".
Tommy Delson
Ranch Hand

Joined: Apr 13, 2011
Posts: 206
Try to take out " <aop:scoped-proxy/>" since your "userPreference" bean is declared as "singleton".

See and recheck Spring document for details....



Here is the recap from Spring doc if you missed:

Note

You do not need to use the <aop:scoped-proxy/> in conjunction with beans that are scoped as singletons or prototypes. It is an error to try to create a scoped proxy for a singleton bean (and the resulting BeanCreationException will certainly set you straight in this regard).


OCPJP6-05-11
"Your life is in your hands, to make of it what you choose."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring session="scope"