JSF1.2&的集成问题春季安全

时间:2011-06-02 13:15:07

标签: jsf spring-security

我在我的JSF 1.2项目中实现了Spring安全性。这在JBoss 5.0.1中成功部署了,但是当我尝试访问我的应用程序的登录页面时,它给了我以下异常

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)

从这个跟踪中我猜测一下spring bean在初始化之前如何尝试使用面向上下文。

以下是我的项目结构:

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)

这里有一件事值得一提的是,我想把我所有的春季证券罐都放在耳朵的lib目录中,当我将所有我的证券罐直接放在耳朵(耳内容)而不是在lib中时,这个例外就不会发生。

请建议我这是否是我的项目结构的问题?

更新:这是我的明确内容:

   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

这是web.xml条目的一部分:

        <!--  Delegating to a Spring-managed bean that implements the Filter interface -->
<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    <init-param>
        <param-name>targetBean</param-name>
        <param-value>filterChainProxy</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
</filter-mapping>

    <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

1 个答案:

答案 0 :(得分:2)

FacesContextFacesServlet创建。因此,当它为null时,则表示您未调用FacesServlet。您需要确保浏览器请求网址与您<url-pattern>中确定的FacesServlet的{​​{1}}一致。

如果是例如

web.xml

然后您需要确保以

的形式调用登录页面
  

http://localhost:8080/myWar/login.jsf

因此

  

http://localhost:8080/myWar/login.xhtml