WebApplicationContextUtils.getWebApplicationContext() returns null in Servl
686997Mar 11 2009 — edited Mar 12 2009I'm developing an ADF UI+BC application on Jdeveloper 11g and deploying it to Tomcat6.
My web.xml looks like:
-----
<web-app>
<listener>
<listener-class>oracle.x.AppListener</listener-class>
</listener>
...
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
-----
com.x.AppListener.java looks like:
-----
package com.x;
public class AppListener implements ServletContextListener {
public static ServletContext servletContext;
public void contextInitialized(ServletContextEvent context) {
AppListener.servletContext = context.getServletContext();
System.out.println("-------------servletContext:"+servletContext+"!!!!!!");
WebApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(AppListener.servletContext);
System.out.println("-------------appContext:"+appContext+"!!!!!!");
}
...
}
-----
In the Tomcat log, on startup, i can see the following:
-----
-------------servletContext:org.apache.catalina.core.ApplicationContextFacade@426e05!!!!!!
-------------appContext:null!!!!!!
-----
servletContext is getting set but appContext is being returned as null from WebApplicationContextUtils.getWebApplicationContext().
Any ideas why this might happen?