title: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener adding spring-security
body: <p>I've got the error </p>
  
  <blockquote>
    <p>java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener</p>
  </blockquote>
  
  <p>when deploying only if I include the following piece of code between "Spring Security" and "END Spring Security" in the file <code>web.xml</code>. If I remove this part of the code in the XML everything works fine.</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" 
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
          version="2.5"&gt;
  
  
   &lt;!-- Spring MVC --&gt;
   &lt;servlet&gt;
   &lt;servlet-name&gt;dispatch&lt;/servlet-name&gt;
   &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
   &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
   &lt;servlet-name&gt;dispatch&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
   &lt;servlet&gt;
   &lt;servlet-name&gt;floorOperationWS&lt;/servlet-name&gt;
   &lt;servlet- class&gt;org.springframework.ws.transport.http.MessageDispatcherServlet&lt;/servlet-class&gt;
   &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;floorOperationWS&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/floorOperationWS/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;updatefloorServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.services.endpoint.UpdatefloorEventServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;updatefloorServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/updatefloorWS&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
      &lt;!-- Spring Security --&gt;
  
       &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/spring-security.xml
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
      &lt;!-- END Spring Security --&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>-- spring-security.xml :</p>
  
  <pre><code>   &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="http://www.springframework.org/schema/beans" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-3.2.xsd"&gt;
  
  &lt;http auto-config="true"&gt;
      &lt;intercept-url pattern="/admin**" access="ROLE_USER" /&gt;
  &lt;/http&gt;
  
  &lt;authentication-manager&gt;
      &lt;authentication-provider&gt;
          &lt;user-service&gt;
              &lt;user name="mkyong" password="123456" authorities="ROLE_USER" /&gt;
          &lt;/user-service&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p></p>
  
  <p>-- MAVEN dependencies:</p>
  
  <pre><code>            &lt;properties&gt;        
      &lt;java-version&gt;1.7&lt;/java-version&gt;
      &lt;!--  org.springframework-version&gt;3.0.5.RELEASE&lt;/org.springframework-v version--&gt;
      &lt;org.springframework-version&gt;4.0.3.RELEASE&lt;/org.springframework-version&gt;
      &lt;spring.security.version&gt;3.2.3.RELEASE&lt;/spring.security.version&gt;
      &lt;org.aspectj-version&gt;1.6.10&lt;/org.aspectj-version&gt;
      &lt;org.slf4j-version&gt;1.5.10&lt;/org.slf4j-version&gt;
      &lt;junit.version&gt;4.11&lt;/junit.version&gt;
  &lt;/properties&gt;
  &lt;dependencies&gt;
      &lt;!-- Spring --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;!-- Exclude Commons Logging in favor of SLF4j --&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;commons-logging&lt;/groupId&gt;
                  &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
               &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;!-- Spring 3 dependencies --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-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;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring Security --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
          &lt;version&gt;${spring.security.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;!-- DB connection --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${org.springframework-version}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>What's causing this error and how can I fix it?</p>