title: j_spring_security_check not invoke when use specific url pattern in http element
body: <p>I'm trying to implement two security realms using spring security. I am using Spring security 3.1.4 RELEASE and Spring 3.2.0 RELEASE. In my web application there are two users and they should be authenticate separately. Therefore I tried to use multiple <strong>http</strong> elements to filter url pattern and redirect to corresponding login page.</p>
  
  <p>Here is my Spring-security.xml.</p>
  
  <pre><code>&lt;beans: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.1.xsd" xmlns:beans="http://www.springframework.org/schema/beans"&gt;
  
   &lt;security:http pattern="/admin/**" auto-config="true" use-expressions="true"&gt;
      &lt;security:form-login login-page="/admin/login" default-target-url="/admin/dashboard"
                           authentication-failure-url="/admin/loginfailed"/&gt;
      &lt;security:logout logout-success-url="/admin/logout"/&gt;
  
      &lt;security:intercept-url pattern="/admin/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/&gt;
      &lt;security:intercept-url pattern="/admin/login" access="permitAll"/&gt;
  
      &lt;security:intercept-url pattern="/admin/*" access="hasRole('ROLE_ADMIN')"/&gt;
  
   &lt;/security:http&gt;
  
   &lt;security:http pattern="/customer/**" auto-config="true" use-expressions="true"&gt;
      &lt;security:form-login login-page="/customer/login" default-target-url="/customer/reports"
                           authentication-failure-url="/customer/loginfailed"/&gt;
      &lt;security:logout logout-success-url="/customer/logout"/&gt;
      &lt;security:intercept-url pattern="/customer/j_spring_security_check" access="permitAll"/&gt;
      &lt;security:intercept-url pattern="/customer/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/&gt;
      &lt;security:intercept-url pattern="/customer/login" access="permitAll"/&gt;
  
      &lt;security:intercept-url pattern="/customer/*" access="hasRole('ROLE_ADMIN')"/&gt;
  
  &lt;/security:http&gt;
  
  
  &lt;beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;beans:property name="jndiName"&gt;
          &lt;beans:value&gt;java:/myDS&lt;/beans:value&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;security:authentication-manager&gt;
      &lt;security:authentication-provider&gt;
          &lt;security:jdbc-user-service data-source-ref="dataSource"
                                      users-by-username-query="SELECT login_name AS username, password, 1 AS enabled
                                          FROM tbl_user WHERE login_name=?"
                                      authorities-by-username-query="SELECT login_name , CASE role_id WHEN 2 THEN 'ROLE_USER' WHEN 1 THEN 'ROLE_ADMIN'ELSE '' END AS authority
              FROM tbl_user WHERE login_name=?"
  
                  /&gt;
      &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>Here is my web.xml</p>
  
  <pre><code>&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;
  </code></pre>
  
  <p>Here is my login.jsp</p>
  
  <pre><code>enter code here
  &lt;c:url value="/j_spring_security_check" var="url" /&gt;
  &lt;form c role="form" action="${url}" method='POST'&gt;
         &lt;div&gt;
             &lt;label&gt;Email&lt;/label&gt;
  
              &lt;div &gt;
                 &lt;input type="email"  name="j_username" id="inputEmail3"
                                 placeholder="Email"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div &gt;
              &lt;labe&gt;Password&lt;/label&gt;
  
               &lt;div&gt;
                    &lt;input type="password"  name="j_password" id="inputPassword3"
                                 placeholder="Password"&gt;
               &lt;/div&gt;
           &lt;/div&gt;
  
            &lt;div class="form-group"&gt;
                &lt;div&gt;
                    &lt;button type="submit"&gt;Sign in&lt;/button&gt;
                &lt;/div&gt;
            &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>When I remove the url patterns in the http elements, it's perfectly works. Actually I can't remove both url patterns. I tried by removing "/customer/**" and it works for customer login. But when url pattern is present, j_spring_security_check 404 not fount error occurred. </p>
  
  <p>According to the spring security documentation, we can add multiple http elements with different url patterns.</p>
  
  <p>Please help me to find a solution for this.</p>