title: Creating a custom login form with Spring Security
body: <p>I'm trying to get the custom login form to work with Spring Security 3.0.</p>
  
  <p>The default login form works fine with the security configuration below.  Then I added the form-login attribute, created the login controller and jsp page to handle the /accounts/logIn URL and now have this problem:  when I enter my guest/guest credentials, I am sent back to the logIn page.</p>
  
  <p>One thing I noticed in the catalina.out log is that the successful check is looking at /j_security_check, whereas the unsuccessful one is looking at /accounts/j_security_check.</p>
  
  <p>Here's my security-config.xml:</p>
  
  <pre><code>&lt;http auto-config="true" use-expressions="true"&gt;
      &lt;form-login login-page="/accounts/logIn" /&gt;&lt;!--ADDED THIS AFTER TESTING DEFAULT LOGIN--&gt;
      &lt;intercept-url pattern="/accounts/logIn" access="permitAll()"/&gt;
      &lt;intercept-url pattern="/**" access="isAuthenticated()"/&gt;
  &lt;/http&gt;
  
  &lt;authentication-manager alias="authenticationManager"&gt;
      &lt;authentication-provider&gt;
   &lt;user-service&gt;
              &lt;user authorities="ROLE_USER" name="guest" password="guest"/&gt;
          &lt;/user-service&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the section of catalina.out that looks relevant:</p>
  
  <p><pre><code>
  DEBUG: org.springframework.security.web.FilterChainProxy - Candidate is: '/accounts/j_spring_security_check'; pattern is /**; matched=true
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 1 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.context.SecurityContextPersistenceFilter@8cbb423'
  DEBUG: org.springframework.security.web.context.HttpSessionSecurityContextRepository - HttpSession returned null object for SPRING_SECURITY_CONTEXT
  DEBUG: org.springframework.security.web.context.HttpSessionSecurityContextRepository - No SecurityContext was available from the HttpSession: org.apache.catalina.sessi\
  on.StandardSessionFacade@4679cf8c. A new one will be created.
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 2 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.authentication.logout.LogoutFilter@5d49453c'
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 3 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@756095fc'
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 4 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.authentication.www.BasicAuthenticationFilter@18170f98'
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 5 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1200d083'
  DEBUG: org.springframework.security.web.savedrequest.DefaultSavedRequest - pathInfo: both null (property equals)
  DEBUG: org.springframework.security.web.savedrequest.DefaultSavedRequest - queryString: arg1=null; arg2=j_username=guest&amp;j_password=guest (property not equals)
  DEBUG: org.springframework.security.web.savedrequest.HttpSessionRequestCache - saved request doesn't match
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 6 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@737951b0'
  DEBUG: org.springframework.security.web.FilterChainProxy - /accounts/j_spring_security_check?j_username=guest&amp;j_password=guest at position 7 of 10 in additional filter\
   chain; firing Filter: 'org.springframework.security.web.authentication.AnonymousAuthenticationFilter@49c06a6d'
  DEBUG: org.springframework.security.web.authentication.AnonymousAuthenticationFilter - Populated SecurityContextHolder with anonymous token: 'org.springframework.secur\
  ity.authentication.AnonymousAuthenticationToken@6faaf9b0: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.securit\
  y.web.authentication.WebAuthenticationDetails@ffff8868: RemoteIpAddress: 0:0:0:0:0:0:0:1%0; SessionId: 0560416CA2D07AFF3040E75867157A95; Granted Authorities: ROLE_ANON\
  YMOUS'
  </pre></code></p>