title: Spring security 3 with primefaces does not work : HTTP 404 .... The requested resource (/j_security_check) is not available
body: <p>I have an issue with using Spring security 3  with primefaces 3 . when i deploy my project i get the login page but when i try to login i get this error</p>
  
  <pre><code>HTTP 404 .... The requested resource (/j_security_check) is not available
  </code></pre>
  
  <p>can you help me guys ? 
  this is my application-security.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &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"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                          http://www.springframework.org/schema/security
                           http://www.springframework.org/schema/security/spring-security-3.2.xsd"&gt;
  
      &lt;global-method-security secured-annotations="enabled"&gt;
      &lt;/global-method-security&gt;
  
      &lt;http auto-config="true" access-denied-page="/accessDenied.jsp"&gt;
  
          &lt;intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
          &lt;intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" /&gt;
  
          &lt;form-login login-page="/login.jsf" default-target-url="/"
              authentication-failure-url="/loginFail" /&gt;
          &lt;logout logout-url="/logout" logout-success-url="/" /&gt;
      &lt;/http&gt;
  
      &lt;authentication-manager&gt;
          &lt;authentication-provider&gt;
              &lt;user-service&gt;
  
                  &lt;user name="jack" password="jack" authorities="ROLE_USER" /&gt;
                  &lt;user name="admin" password="admin" authorities="ROLE_ADMIN" /&gt;
                  &lt;user name="user" password="user" authorities="ROLE_USER" /&gt;
              &lt;/user-service&gt;
          &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  &lt;/beans:beans&gt; 
  </code></pre>
  
  <p>and that's login.xhtml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"&gt;
      &lt;f:view contentType="text/html"&gt;
          &lt;h:head&gt;
              &lt;f:facet name="first"&gt;
                  &lt;meta http-equiv="X-UA-Compatible" content="EmulateIE8" /&gt;
                  &lt;meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/&gt;
                  &lt;title&gt;Acceuil&lt;/title&gt;
              &lt;/f:facet&gt;
  
              &lt;/h:head&gt;
      &lt;h:form id="loginForm" prependId="false"&gt;
   &lt;p:panelGrid columns="2"&gt;
    &lt;h:outputLabel for="j_username" value="Username:" /&gt;
    &lt;p:inputText id="j_username" required="true"
     value="#{loginBean.username}"&gt;
    &lt;/p:inputText&gt;
  
    &lt;h:outputLabel for="j_password" value="Password:" /&gt;
    &lt;p:password id="j_password" required="true"
     value="#{loginBean.password}"&gt;
    &lt;/p:password&gt;
  
  
    &lt;f:facet name="footer"&gt;
     &lt;p:commandButton type="submit" id="login" ajax="false"
      actionListener="#{loginBean.doLogin()}" value="Login" /&gt;
    &lt;/f:facet&gt;
   &lt;/p:panelGrid&gt;
  &lt;/h:form&gt;
              &lt;/f:view&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and My LoginBean :</p>
  
  <pre><code>import java.io.IOException;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  import javax.faces.context.ExternalContext;
  import javax.faces.context.FacesContext;
  import javax.servlet.*;
  
  
  
  @ManagedBean(name="loginBean")
  @RequestScoped
  public class LoginBean {
      private String username;
      private String password;
      public String getUsername() {
          return username;
      }
      public void setUsername(String username) {
          this.username = username;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
      public String doLogin() throws IOException, ServletException {
           ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
  
           RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
            .getRequestDispatcher("/j_spring_security_check");
  
           dispatcher.forward((ServletRequest) context.getRequest(),
            (ServletResponse) context.getResponse());
  
           FacesContext.getCurrentInstance().responseComplete();
  
           return null;
  
          }
  
  }
  </code></pre>