title: 404 Error on /spring_security_login Spring Security 3.2 after migrating from Tomcat 6 to Tomcat 7
body: <p>It's been now three days that I'm battling to make my application work again.
  The pitch : I had an application using Spring Security 3.2 and running well on Tomcat 6.</p>
  
  <p>I want to migrate all my apps on Tomcat 7, so that's why I'm trying that.</p>
  
  <p>BUT : every time I access to the root of my app, I get a 404 error page, with /spring_security_login written in the URL. 
  For the /spring_security_login written, it seems partially legit, because Spring is set to create the login form on its own. But why the 404 error ? 
  On Tomcat 6, with the same web.xml and applicationContext-security, the site is running well.</p>
  
  <p>Last but not least, my login is made through the Spring Security ldap provider, so it adds one more level of complexity...</p>
  
  <p>Here is my web.xml :</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/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;MYAPP&lt;/display-name&gt;
  
    &lt;!-- où se trouve la conf spring: --&gt;
    &lt;context-param&gt;
        &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
        &lt;param-value&gt;/WEB-INF/applicationContext-security.xml&lt;/param-value&gt;
    &lt;/context-param&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;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;!-- Reads request input using UTF-8 encoding --&gt;
    &lt;filter&gt;
      &lt;filter-name&gt;characterEncodingFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;encoding&lt;/param-name&gt;
        &lt;param-value&gt;UTF-8&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
        &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
        &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
    &lt;/filter&gt;
  
    &lt;filter-mapping&gt;
      &lt;filter-name&gt;characterEncodingFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&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;!-- configuration spring --&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;myapp-webapp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;3&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;myapp-webapp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/remoting/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.png&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.js&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.css&lt;/url-pattern&gt;
      &lt;url-pattern&gt;*.gif&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
    &lt;resource-ref&gt;
      &lt;description&gt;DB Connection&lt;/description&gt;
      &lt;res-ref-name&gt;jdbc/myapp_database&lt;/res-ref-name&gt;
      &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
      &lt;res-auth&gt;Container&lt;/res-auth&gt;
    &lt;/resource-ref&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And my applicationContext-security.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://www.springframework.org/schema/security"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"&gt;
  
      &lt;s:global-method-security secured-annotations="disabled"&gt;
      &lt;/s:global-method-security&gt;
  
      &lt;s:http pattern="/styles/**" security="none"/&gt;
      &lt;s:http pattern="/js/**" security="none"/&gt;
      &lt;s:http pattern="/img/**" security="none"/&gt;
      &lt;s:http pattern="/html/**" security="none"/&gt;
      &lt;s:http pattern="/remoting/**" security="none"/&gt;
  
      &lt;!-- config ldap activee use-expressions="true"  --&gt;
      &lt;s:http auto-config="true" create-session="always" access-decision-manager-ref="accessDecisionManager"&gt;
          &lt;s:intercept-url pattern="/cancelPreviousAction.do" access="P_MYAPP_RW" /&gt;
          &lt;s:intercept-url pattern="/**" access="P_MYAPP_RO" /&gt;
          &lt;s:session-management&gt;
              &lt;s:concurrency-control max-sessions="1" /&gt;
          &lt;/s:session-management&gt;
          &lt;s:form-login /&gt;
          &lt;s:logout/&gt;
      &lt;/s:http&gt;
  
      &lt;s:authentication-manager&gt;
          &lt;s:authentication-provider ref="ldapProvider"&gt;&lt;/s:authentication-provider&gt;
      &lt;/s:authentication-manager&gt;
  
      &lt;bean id="contextSource"
          class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"&gt;
          &lt;constructor-arg value="..." /&gt;
          &lt;property name="userDn" value="..." /&gt;
          &lt;property name="password" value="..." /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="ldapProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider"&gt;
          &lt;constructor-arg&gt;
              &lt;bean class="org.springframework.security.ldap.authentication.BindAuthenticator"&gt;
                  &lt;constructor-arg ref="contextSource" /&gt;
                  &lt;property name="userSearch"&gt;
                      &lt;bean id="userSearch"
                          class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch"&gt;
                          &lt;constructor-arg index="0" value="..." /&gt;
                          &lt;constructor-arg index="1" value="..." /&gt;
                          &lt;constructor-arg index="2" ref="..." /&gt;
                      &lt;/bean&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
          &lt;/constructor-arg&gt;
  
          &lt;constructor-arg&gt;
              &lt;bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator"&gt;
                  &lt;constructor-arg ref="contextSource" /&gt;
                  &lt;constructor-arg value="..." /&gt;
                  &lt;property name="rolePrefix" value="" /&gt;
                  &lt;property name="searchSubtree" value="true" /&gt;
                  &lt;property name="convertToUpperCase" value="false" /&gt;
              &lt;/bean&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
  
      &lt;bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased"&gt;
          &lt;property name="allowIfAllAbstainDecisions" value="false" /&gt;
          &lt;property name="decisionVoters"&gt;
              &lt;bean class="org.springframework.security.access.vote.RoleVoter"&gt;
                  &lt;property name="rolePrefix" value=""/&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt; 
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Anybody has a clue ?</p>
  
  <p>I though one time that it might be my Tomcat conf that would be the cause, but now when I call the root url of my app, the /spring_security_login appends itself in the url, so I think the redirection inside Spring Seuciryt works well...</p>
  
  <p>NB : When I remove the spring Security filter from the web.xml file, the app works well (except the login/security part needless to say).</p>
  
  <p>Thanks in advance !</p>