title: Why Spring Context is loaded twice?
body: <p>I have web project with Spring and Spring security.
  My web.xml:</p>
  
  <pre><code>    &lt;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" &gt;
          &lt;display-name&gt;BillBoard
          &lt;/display-name&gt;
          &lt;session-config&gt;
              &lt;session-timeout&gt;
                  30
              &lt;/session-timeout&gt;
          &lt;/session-config&gt;
          &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.security.web.session.HttpSessionEventPublisher&lt;/listener-class&gt;
          &lt;/listener&gt;
          &lt;context-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:security-config.xml classpath:billboard-servlet.xml&lt;/param-value&gt;
          &lt;/context-param&gt;
          &lt;servlet&gt;
              &lt;servlet-name&gt;billboard&lt;/servlet-name&gt;
              &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
              &lt;init-param&gt;
                  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
                  &lt;param-value&gt;classpath:security-config.xml classpath:billboard-servlet.xml&lt;/param-value&gt;
              &lt;/init-param&gt;
              &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  
          &lt;/servlet&gt;
          &lt;servlet-mapping&gt;
              &lt;servlet-name&gt;billboard&lt;/servlet-name&gt;
              &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
          &lt;/servlet-mapping&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;/web-app&gt;
  </code></pre>
  
  <p>In server logs I see Spring context is loaded twice (spring bean initialization, database createtion...). At first time DispatcherServlet does it, and at the secont time ContextLoaderListener. How can I fix it?</p>
  
  <p>In <a href="http://static.springsource.org/spring-security/site/tutorial.html" rel="noreferrer">this</a> tutorial I see that if contextParam is presented then servlet init-params are not required. But if I remove init params I have error: "org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/billboard-servlet.xml]". Dispather servlet finds context-configuration in default location.</p>