Dear Guys,
To my understanding, in order to get a bean, we should get the application context and call getBean. In the
servlet layer it is easy, all we need to do is
In web.xml file while configuration ContextLoaderListener its worki ng fine. But I have removed ContextLoaderListener in web.xml getting null pointer in exception (userSessionCache = (UserSessionCache) webAppCtxt.getBean(“User”); in this line.)
cache.xml:
<bean id="userSessionCache" class="com.xxx.cache.UserSessionCache"/>
//
test the spring framework
sessionListener.java
WebApplicationContext webAppCtxt = WebApplicationContextUtils.getWebApplicationContext(event.getSession()
.getServletContext());
private UserSessionCache userSessionCache;
userSessionCache = (UserSessionCache) webAppCtxt.getBean(“User”); I am getting null pointer exception in this line.
ERROR [SessionListener] Exception Occured in Session Listener
java.lang.NullPointerException
at com.xxx.handler.SessionListener.sessionDestroyed(SessionListener.java:61)
Is it possible to get the “WebApplicationContext” in spring mvc without ContextLoaderListener?
Thanks,
SR