title: Problem in integration of JSF1.2 & Spring Security
body: <p>I am implementing spring security in my JSF 1.2 project.This deployed successfully in JBoss 5.0.1 but it gives me following exceptions when I try to access login page of my application</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: FacesContext must not be null
  at org.springframework.util.Assert.notNull(Assert.java:112)
  at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
  at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
  at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getWebApplicationContext(SpringBeanFacesELResolver.java:91)
  at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getBeanFactory(SpringBeanFacesELResolver.java:79)
  at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:50)
  at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
  </code></pre>
  
  <p>From this trace I am guessing that some how spring beans trying to use faces context before it initializes.</p>
  
  <p>Following is my project structure :</p>
  
  <pre><code>MyEar
  |-- lib\ (contains all spring security jar files)  
  |
  |
  |-- myWar
         |-- META-INF/MANIFEST.MF (entries for spring security jars)
         |
         |-- WEB-INF
                 |-- applicationContext.xml 
                 |-- lib\ (local jar files jsf,facelets etc)
  </code></pre>
  
  <p>Here one thing is important to mention is that I want all my spring securities jar in ear's lib directory and this exception is not happening when I put all my spring securities jar directly under ear (earcontent) not in lib.</p>
  
  <p>Please suggest me whether this is the issue with structure of my project of something else?</p>
  
  <p><strong>UPDATE</strong>:Here is my manifest content:</p>
  
  <pre><code>   Manifest-Version: 1.0
     Class-Path: lib/aopalliance-1.0.jar 
     lib/mysql-connector-java-5.1.7-bin.jar 
     lib/org.springframework.aop-3.0.5.RELEASE.jar 
     lib/org.springframework.asm-3.0.5.RELEASE.jar 
     lib/org.springframework.beans-3.0.5.RELEASE.jar 
     lib/org.springframework.context-3.0.5.RELEASE.jar 
     lib/org.springframework.core-3.0.5.RELEASE.jar 
     lib/org.springframework.expression-3.0.5.RELEASE.jar 
     lib/org.springframework.transaction-3.0.5.RELEASE.jar 
     lib/org.springframework.web-3.0.5.RELEASE.jar 
     lib/spring-security-config-3.0.5.RELEASE.jar 
     lib/spring-security-core-3.0.5.RELEASE.jar 
     lib/spring-security-taglibs-3.0.5.RELEASE.jar 
     lib/spring-security-web-3.0.5.RELEASE.jar
  </code></pre>
  
  <p>here is some part of web.xml entries:</p>
  
  <pre><code>        &lt;!--  Delegating to a Spring-managed bean that implements the Filter interface --&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;init-param&gt;
          &lt;param-name&gt;targetBean&lt;/param-name&gt;
          &lt;param-value&gt;filterChainProxy&lt;/param-value&gt;
      &lt;/init-param&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;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
  &lt;/filter-mapping&gt;
  
      &lt;servlet&gt;
        &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
        &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&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;Faces Servlet&lt;/servlet-name&gt;
        &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>