title: j_spring_security_check - The requested resource is not available
body: <p>Sending my login form is not working.
  I get the message "The requested resource is not available", when sending the login form, which accesses /j_spring_security_check with the standard filter.</p>
  
  <p>My application-servlet.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"
  xmlns:security="http://www.springframework.org/schema/security"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-4.0.xsd"&gt;
  
  &lt;!-- enable use-expressions --&gt;
  &lt;http auto-config="true" use-expressions="true"&gt;
  
      &lt;intercept-url pattern="/inside**" access="hasRole('ROLE_USER')" /&gt;
  
      &lt;!-- access denied page --&gt;
      &lt;access-denied-handler error-page="/403" /&gt;
  
      &lt;form-login 
          login-page="/login" 
          default-target-url="/welcome" 
          authentication-failure-url="/login?error" 
          username-parameter="username"
          password-parameter="password" /&gt;
  
      &lt;logout logout-success-url="/login?logout"  /&gt;
  
      &lt;!-- enable csrf protection --&gt;
      &lt;csrf/&gt;
  &lt;/http&gt;
  
  &lt;!-- Select users and user_roles from database --&gt;
  &lt;authentication-manager&gt;
    &lt;authentication-provider&gt;
      &lt;jdbc-user-service data-source-ref="dataSource"
        users-by-username-query=
          "select email,password from users where username=?" /&gt;
    &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  
  &lt;http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint"&gt;
  
      &lt;intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" /&gt;
      &lt;intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" /&gt;
      &lt;logout logout-success-url="/index.jsp" invalidate-session="true" /&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p></p>
  
  <p>The spring-database.xml looks like this:</p>
  
  <pre><code>&lt;beans xmlns="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"&gt;
  
  &lt;bean id="daoImpl" class="com.afterguard.sailplanner.dao.DaoImpl"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
  
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/sailplanner" /&gt;
      &lt;property name="username" value="sailplanner" /&gt;
      &lt;property name="password" value="sailplanner2" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>And my spring-security.xml like this:</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"
  xmlns:security="http://www.springframework.org/schema/security"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  http://www.springframework.org/schema/security
  http://www.springframework.org/schema/security/spring-security-4.0.xsd"&gt;
  
  &lt;!-- enable use-expressions --&gt;
  &lt;http auto-config="true" use-expressions="true"&gt;
  
      &lt;intercept-url pattern="/inside**" access="hasRole('ROLE_USER')" /&gt;
  
      &lt;!-- access denied page --&gt;
      &lt;access-denied-handler error-page="/403" /&gt;
  
      &lt;form-login 
          login-page="/login" 
          default-target-url="/welcome" 
          authentication-failure-url="/login?error" 
          username-parameter="username"
          password-parameter="password" /&gt;
  
      &lt;logout logout-success-url="/login?logout"  /&gt;
  
      &lt;!-- enable csrf protection --&gt;
      &lt;csrf/&gt;
  &lt;/http&gt;
  
  &lt;!-- Select users and user_roles from database --&gt;
  &lt;authentication-manager&gt;
    &lt;authentication-provider&gt;
      &lt;jdbc-user-service data-source-ref="dataSource"
        users-by-username-query=
          "select email,password from users where username=?" /&gt;
    &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  
  &lt;http auto-config="false" entry-point-ref="authenticationProcessingFilterEntryPoint"&gt;
  
      &lt;intercept-url pattern="/resettingPassword.do**" access="ROLE_ADMIN" /&gt;
      &lt;intercept-url pattern="/resetPassword.do**" access="ROLE_ADMIN" /&gt;
      &lt;logout logout-success-url="/index.jsp" invalidate-session="true" /&gt;
  &lt;/http&gt;
  </code></pre>
  
  <p></p>
  
  <p>I have the following 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" 
              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;SailPlanner&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;sailplanner&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;sailplanner&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/welcome&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/users&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/create_event&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/save_event&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/login&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/logout&lt;/url-pattern&gt;
      &lt;url-pattern&gt;/403&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;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
              /WEB-INF/sailplanner-servlet.xml,
              /WEB-INF/spring-security.xml,
              /WEB-INF/spring-database.xml
          &lt;/param-value&gt;
    &lt;/context-param&gt; 
  
          &lt;!-- Spring Security --&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>My setup looks like this:
  <a href="https://i.stack.imgur.com/hRsmb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hRsmb.png" alt="enter image description here"></a></p>