title: Spring Security Login Error : HTTP Status 404 - /j_spring_security_check
body: <p>Hi I am trying to configure spring security on my application.But once I enter the username and password and submit the form, I get error</p>
  
  <p><code>HTTP Status 404 - /j_spring_security_check The requested resource is not available.</code></p>
  
  <p><img src="https://i.stack.imgur.com/Z2JKl.png" alt="enter image description here"></p>
  
  <p>Following are the my configuration files :</p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&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&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;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/applicationContext.xml,/WEB-INF/taskTracker-app.xml,/WEB-INF/taskTracker-servlet.xml,/WEB-INF/taskTracker-security.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;taskTracker&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;taskTracker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p><strong>taskTracker-servlet.xml</strong></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:tx="http://www.springframework.org/schema/tx"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/aop 
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
   http://www.directwebremoting.org/schema/spring-dwr
   http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"&gt;
  
      &lt;bean id="TaskTrackerLoginController"
          class="org.springframework.web.servlet.mvc.ParameterizableViewController"&gt;
          &lt;property name="viewName"&gt;
              &lt;value&gt;/taskTracker/sign-in&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="TaskTrackerErrorController"
          class="org.springframework.web.servlet.mvc.ParameterizableViewController"&gt;
          &lt;property name="viewName"&gt;
              &lt;value&gt;/taskTracker/error&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="WelcomeController" class="com.tracker.web.controllers.WelcomeController"&gt;
          &lt;property name="BusinessLogic"&gt;
              &lt;ref bean="BusinessLogic" /&gt;
          &lt;/property&gt;
          &lt;property name="viewName"&gt;
              &lt;value&gt;/taskTracker/welcome&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="nonSecurePageMappings"
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
          &lt;property name="mappings"&gt;
              &lt;props&gt;
                  &lt;prop key="/taskTracker/sign-in.html"&gt;TaskTrackerLoginController&lt;/prop&gt;
                  &lt;prop key="/taskTracker/error.html"&gt;TaskTrackerErrorController&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;bean id="PageMappings"
          class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
          &lt;property name="mappings"&gt;
              &lt;props&gt;
  
                  &lt;prop key="/taskTracker/welcome.html"&gt;WelcomeController&lt;/prop&gt;
  
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
          &lt;property name="viewClass"&gt;
              &lt;value&gt;org.springframework.web.servlet.view.JstlView&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/jsp/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>taskTracker-security.xml</strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:security="http://www.springframework.org/schema/security"
      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.0.xsd"&gt;
  
      &lt;bean id="SecurityService" class="com.tracker.web.security.SecurityService"&gt;
          &lt;property name="BusinessLogic"&gt;
              &lt;ref bean="BusinessLogic" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;security:http access-denied-page="/taskTracker/tracker/error.html" auto-config="false"&gt;
          &lt;security:session-management invalid-session-url="/taskTracker/sign-in.html"&gt;
          &lt;/security:session-management&gt;
          &lt;security:form-login login-page="/taskTracker/sign-in.html" default-target-url="/taskTracker/welcome.html"
              always-use-default-target="false" authentication-failure-url="/taskTracker/sign-in.html?error=1" /&gt;
          &lt;security:logout invalidate-session="true" logout-success-url="/taskTracker/sign-in.html" /&gt;
          &lt;security:intercept-url pattern="/taskTracker/sign-in.html*" filters="none" /&gt;
          &lt;security:intercept-url pattern="/taskTracker/welcome.html*" /&gt;
      &lt;/security:http&gt;
  
      &lt;security:authentication-manager&gt;
          &lt;security:authentication-provider user-service-ref="SecurityService" /&gt;
      &lt;/security:authentication-manager&gt;
  
  &lt;/beans&gt; 
  </code></pre>
  
  <p><strong>taskTracker-app.xml</strong></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:tx="http://www.springframework.org/schema/tx"
      xmlns:aop="http://www.springframework.org/schema/aop" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/aop 
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
   http://www.directwebremoting.org/schema/spring-dwr
   http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd"&gt;
  
      &lt;bean id="userDao" class="com.tracker.data.dao.jdbc.UserJdbcDao"&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="BusinessLogic" class="com.tracker.business.logic.TrackerBusinessLogicImpl"&gt;
          &lt;property name="userLogic"&gt;
              &lt;ref bean="userLogic" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="userLogic" class="com.tracker.business.logic.user.UserLogic"&gt;
          &lt;property name="userDao"&gt;
              &lt;ref bean="userDao" /&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>SecurityService.java</strong></p>
  
  <pre><code>package com.tracker.web.security;
  
  import org.apache.log4j.Logger;
  import org.springframework.dao.DataAccessException;
  import org.springframework.security.core.userdetails.UserDetails;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.core.userdetails.UsernameNotFoundException;
  
  import com.tracker.business.logic.TrackerBusinessLogic;
  import com.tracker.business.model.User;
  
  public class SecurityService implements UserDetailsService {
      private final static Logger log = Logger.getLogger(SecurityService.class);
      private TrackerBusinessLogic trackerBusinessLogic;
  
      public UserDetails loadUserByUsername(String username)
              throws UsernameNotFoundException, DataAccessException {
  
          String errMsg = "User with username: " + username;
  
          User user = trackerBusinessLogic.loadUser(username);
          if(user!=null) {
              // user has been loaded
          } else {
              log.error("User with username: " + username + " not found");
          }
          return user;
      }
  
      public TrackerBusinessLogic getBusinessLogic() {
          return trackerBusinessLogic;
      }
  
      public void setBusinessLogic(TrackerBusinessLogic trackerBusinessLogic) {
          this.trackerBusinessLogic = trackerBusinessLogic;
      }
  }
  </code></pre>
  
  <p><strong>sign-in.jsp</strong></p>
  
  <pre><code>&lt;html lang="en-US"&gt;
  &lt;head&gt;
      &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="login"&gt;
      &lt;h1&gt;Task Tracker Login&lt;/h1&gt;
      &lt;form action="/j_spring_security_check" method="post"&gt;
          &lt;input type="text" name="j_username" value="" placeholder="Username" required="required" /&gt;
          &lt;input type="password" name="j_password" placeholder="Password" required="required" /&gt;
          &lt;input type="hidden" name="referrer" value="${param.referrer}" /&gt;
          &lt;input type="submit" value="Let me in." class="btn btn-primary btn-block btn-large"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>Please help me with what am I missing here. Thank You.</p>