title: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
body: <p>Im trying to integrate spring with JSF and I added the following in web.xml,</p>
  
  <pre><code>&lt;listener&gt;  
  &lt;listener-class&gt;
     org.springframework.web.context.ContextLoaderListener
  &lt;/listener-class&gt;  
  &lt;/listener&gt;  
  
  &lt;listener&gt; 
  &lt;listener-class&gt;
   org.springframework.web.context.request.RequestContextListener
  &lt;/listener-class&gt;    
  &lt;/listener&gt; 
  </code></pre>
  
  <p>I have also added spring-web and common logging in my tomcat classpath in eclipse</p>
  
  <p>There are no build errors , but while running on tomcat 7 im getting the following error,</p>
  
  <pre><code>  java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
  at java.lang.ClassLoader.findBootstrapClass(Native Method)
  at java.lang.ClassLoader.findBootstrapClassOrNull(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>   java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
  at java.lang.ClassLoader.findBootstrapClass(Native Method)
  at java.lang.ClassLoader.findBootstrapClassOrNull(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  </code></pre>
  
  <p>These are my settings,</p>
  
  <ul>
  <li><p>There is a servlet-api jar in tomcat lib</p></li>
  <li><p>In my Pom.xml I have given</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
      &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
      &lt;version&gt;2.5&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
  &lt;/dependency&gt; 
  
   and            
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
          &lt;version&gt;6.0&lt;/version&gt;
      &lt;/dependency&gt; 
  </code></pre></li>
  </ul>
  
  <p>I have tried commenting out the entry in pom.xml also this also but no luck.
  Any help will be appreciated.</p>
  
  <p>This is my pom.xml,</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/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;TimeTracker&lt;/groupId&gt;
  &lt;artifactId&gt;TimeTracker&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;prime-repo&lt;/id&gt;
          &lt;name&gt;PrimeFaces Maven Repository&lt;/name&gt;
          &lt;url&gt;http://repository.primefaces.org&lt;/url&gt;
      &lt;/repository&gt;
  
      &lt;repository&gt;
  &lt;id&gt;Java.Net&lt;/id&gt;
  &lt;url&gt;http://download.java.net/maven/2/&lt;/url&gt;
   &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-io&lt;/groupId&gt;
          &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
          &lt;version&gt;1.3.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-fileupload&lt;/groupId&gt;
          &lt;artifactId&gt;commons-fileupload&lt;/artifactId&gt;
          &lt;version&gt;1.2.2&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- J2ee --&gt;
  
            &lt;dependency&gt;
              &lt;groupId&gt;javax&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
              &lt;version&gt;6.0&lt;/version&gt;
               &lt;scope&gt;provided&lt;/scope&gt; 
          &lt;/dependency&gt; 
  
      &lt;!-- Spring framework --&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;3.2.3.RELEASE&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt; 
  
  &lt;!-- JSR-330 --&gt;
       &lt;dependency&gt;
          &lt;groupId&gt;javax.inject&lt;/groupId&gt;
          &lt;artifactId&gt;javax.inject&lt;/artifactId&gt;
          &lt;version&gt;1&lt;/version&gt;
      &lt;/dependency&gt; 
  
      &lt;!-- PrimeFaces --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
          &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
          &lt;version&gt;3.5&lt;/version&gt;
      &lt;/dependency&gt;
  
  
      &lt;!-- JSF --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
          &lt;version&gt;2.1.13&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
          &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
          &lt;version&gt;2.1.13&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
       &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt; 
  
        &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt; 
  
       &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;version&gt;1.2&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>and the other thing I have noticed is the jar files which gets copied during deployment. Im running the project in tomcat 7 in eclipse. This is the entries in deployment assembly
  /src                             WEB-INF/classes
  /WebContent                        /
  JSF 2.1 (Apache MyFaces 2.1.5)   WEB-INF/lib</p>
  
  <p>is it ok?  or do I have to add maven dependencies also?.but on adding maven dependencies a error mark appears on the project and on maven -> project update. The cross error and the maven dependency entry also disappears on update. Wel, I am trying to integrate JSF with spring</p>
  
  <p>Thanks,
  Pegasus</p>