I am developing a simple web application using Spring framework 3.1.3.RELEASE & MAVEN. My application would not startup unless I take out the listener from web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Tomcat reports the following error:
INFO: Deploying web application archive sampleapp.war
11/12/2012 3:45:03 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
11/12/2012 3:45:03 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/sampleapp] startup failed due to previous errors
My WEB.XML looks as follows:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>EMS</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/*-context.xml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Application Context File is empty at this point:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
</beans>
Below is the JAR files under WEB-INF/lib
eclipselink-2.4.0.jar
javax.persistence-2.0.0.jar
mysql-connector-java-5.1.21.jar
spring-context-3.1.3.RELEASE.jar
spring-core-3.1.3.RELEASE.jar
spring-web-3.1.3.RELEASE.jar
spring-webmvc-3.1.3.RELEASE.jar
Below is the files under WEB-INF
application.properties
spring-context.xml
web.xml
I understand that:
- ContextLoaderListener is available in spring-web-3.1.3.RELEASE.jar
- If the JAR is available in WEB-INF/lib then it should be picked
by TOMCAT.
What am I doing wrong?
The problem was missing Spring Dependencies in my POM file. I initially had the following dependencies in the POM
I enabled debugging on tomcat logging.properties to see that I was getting a class ava.lang.NoClassDefFoundError as I added dependencies (one at a time) the ava.lang.NoClassDefFoundError kept changing until all dependencies were satisfied. The ContextLoaderListener started up OK after that. The dependencies I added are:
I