title: Tomcat Context initialization failed
body: <p>I have project with two modules: 1) Midtier &amp; 2) webapp. </p>
  
  <p>My mid-tier has beans configuration file that does the component scan for the specified packages to load beans. One of such class I have created is ApplicationContextUtils which extends ApplicationContextAware interface which is in the jar SPRING-CONTEXT. (Yes I have tagged the class ApplicationContextUtils with annotation @Component). The pom of this project has declared spring-context-3.2.4.RELEASE as the dependent jar &amp; I can see it in the maven dependencies. I tested this class alone by running a test which loads all the beans &amp; it ran well.</p>
  
  <p>Now, moving onto webapp, webapp's pom describes the midtier as its dependency. I can see this mid-tier project is listed as maven dependency in webapps. Deploying this project from eclipse to Tomcat I got following error:</p>
  
  <pre><code>org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.jms.testjms.ApplicationContextUtils] for bean with name 'applicationContextUtils' defined in file [F:\Projects\ActiveMQ\JMSProject\target\classes\com\jms\testjms\ApplicationContextUtils.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
  .
  .
  .
  Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
  (&amp; lot of error chains ..)
  </code></pre>
  
  <p>The only reasoning I can get is the jar spring-context is not in the class path. But, when I checked in the WEB-INF/lib, of course there is the jar spring-context-3.2.4.RELEASE which is the source for interface ApplicationContextAware. I am not sure why spring cannot find this interface.</p>
  
  <p>I am using spring 3.2.4. My web.xml is using ContextLoaderListener for loading resources during the start up. The project is build using maven.</p>
  
  <p>Any insights would be greatly appreciated.</p>
  
  <p>POM from mid-tier:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.jms.test&lt;/groupId&gt;
  &lt;artifactId&gt;JmsTest&lt;/artifactId&gt;
  &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  &lt;name&gt;Spring Utility&lt;/name&gt;
  &lt;url&gt;http://www.springframework.org&lt;/url&gt;
  &lt;description&gt;
      &lt;![CDATA[
    This project is a minimal jar utility with Spring configuration.
  ]]&gt;
  &lt;/description&gt;
  &lt;properties&gt;
      &lt;maven.test.failure.ignore&gt;true&lt;/maven.test.failure.ignore&gt;
      &lt;spring.framework.version&gt;3.2.4.RELEASE&lt;/spring.framework.version&gt;
  &lt;/properties&gt;   &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.7&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.14&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
          &lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
          &lt;version&gt;5.7.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
          &lt;artifactId&gt;activemq-spring&lt;/artifactId&gt;
          &lt;version&gt;5.8.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
          &lt;artifactId&gt;activemq-pool&lt;/artifactId&gt;
          &lt;version&gt;5.8.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.5&lt;/source&gt;
                  &lt;target&gt;1.5&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
      &lt;/plugins&gt;
  &lt;/build&gt; 
  </code></pre>
  
  <p></p>
  
  <p>pom from webapp:</p>
  
  <pre><code> &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;JmsProtoWebApp&lt;/groupId&gt;
    &lt;artifactId&gt;JMSWebApp&lt;/artifactId&gt;
   &lt;packaging&gt;war&lt;/packaging&gt;
   &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
   &lt;name&gt;JMSWebApp Maven Webapp&lt;/name&gt;
   &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
  &lt;properties&gt;
      &lt;maven.test.failure.ignore&gt;true&lt;/maven.test.failure.ignore&gt;
      &lt;spring.framework.version&gt;3.2.4.RELEASE&lt;/spring.framework.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.7&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j&lt;/artifactId&gt;
          &lt;version&gt;1.2.14&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
     &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;6.0.37&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.jms.test&lt;/groupId&gt;
          &lt;artifactId&gt;JmsTest&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt; 
  
    &lt;build&gt;
      &lt;finalName&gt;JMSWebApp&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>project structure &amp; deployment assembly:
  <a href="http://imgur.com/zydcqSm" rel="nofollow">http://imgur.com/zydcqSm</a></p>