java - 我需要什么配置和库才能在 jsf 项目中使用 spring security taglibs?

标签 java spring jsf spring-security facelets

我想在我的 jsf 项目中使用 spring security taglibs,所以我对项目做了以下更改,但我得到了这个异常:

Error occurred during deployment: Exception while loading the app :

java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: Source Document: jar:file:/C:/Users/omid4/Desktop/omidircs/final/omidircs/omidircs/build/web/WEB- iNF/lib/org.springframework.faces-2.3.1.RELEASE.jar!/META-INF/faces-config.xml Cause: Unable to create a new instance of >'org.springframework.faces.webflow.FlowActionListener': java.lang.reflect.InvocationTargetException.

我在这里做错了什么?我有其他配置吗? 我使用:

netbeans 7.1.2 --spring mvc 3.0.6-- spring security 3.1.1--glassfish 3.1.2 and jsf 2.1

springsecurity.taglib.xml:

   <!DOCTYPE facelet-taglib PUBLIC
  "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
  "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
    <namespace>http://www.springframework.org/security/tags</namespace>
    <tag>
        <tag-name>authorize</tag-name>
        <handler-class>org.springframework.faces.security.FaceletsAuthorizeTagHandler</handler-class>
    </tag>
    <function>
        <function-name>areAllGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areAllGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>areAnyGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areAnyGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>areNotGranted</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean areNotGranted(java.lang.String)</function-signature>
    </function>
    <function>
        <function-name>isAllowed</function-name>
        <function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
        <function-signature>boolean isAllowed(java.lang.String, java.lang.String)</function-signature>
    </function>
</facelet-taglib>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">


<!--  /========================jsf config=============================/-->

  <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>#{sessionManager.theme}</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
     <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>/index.xhtml</welcome-file>
    </welcome-file-list>

  <!--  /========================spring config=============================/-->  

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
            /WEB-INF/spring-security.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
        <param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
    <listener-class>
      org.springframework.security.web.session.HttpSessionEventPublisher
    </listener-class>
  </listener>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>
            org.springframework.web.filter.DelegatingFilterProxy
        </filter-class>
    </filter>

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

</web-app>

我的页面.xhtml:

xmlns:sec="http://www.springframework.org/security/tags"
.
.
.
<sec:authorize access="ROLE_SUPERADMIN">
      <h:outputText value="test" />                          
</sec:authorize>

我的库:

    org.springframework.cglib-2.2   3.0.6.RELEASE
    org.springframework.aop 3.0.6.RELEASE
    org.springframework.asm 3.0.6.RELEASE
    org.springframework.aspects 3.0.6.RELEASE
    org.springframework.beans   3.0.6.RELEASE
    org.springframework.context 3.0.6.RELEASE
    org.springframework.context.support 3.0.6.RELEASE
    org.springframework.core    3.0.6.RELEASE
    org.springframework.expression  3.0.6.RELEASE
    org.springframework.instrument 3.0.6.RELEASE
    org.springframework.expression  3.0.6.RELEASE
    org.springframework.jdbc    3.0.6.RELEASE
    org.springframework.jms 3.0.6.RELEASE
    org.springframework.orm 3.0.6.RELEASE
    org.springframework.oxm 3.0.6.RELEASE
    org.springframework.test    3.0.6.RELEASE
    org.springframework.tx  3.0.6.RELEASE
    org.springframework.web 3.0.6.RELEASE
    org.springframework.webmvc-portlet  3.0.6.RELEASE
    org.springframework.webmvc  3.0.6.RELEASE
    org.springframework.struts  3.0.6.RELEASE
    commons-logging-1.1.1
    jsf 2.1-jsf-api
    jsf 2.1 -jsf-impl
    jstl 1.1-standard
    jstl 1.1-jstl
    spring-security-ldap-3.1.1.RELEASE.jar
    spring-security-config-3.1.1.RELEASE.jar
    spring-security-core-3.1.1.RELEASE.jar
    spring-security-taglibs-3.1.1.RELEASE.jar
    spring-security-web-3.1.1.RELEASE.jar
    org.springframework.webflow-2.0.3.jar
    org.springframework.binding-2.0.3.jar

最佳答案

我通过删除库解决了这个问题: org.springframework.webflow-2.0.3.jar org.springframework.binding-2.0.3.jar

并从 http://www.springsource.org/download/community?project=Spring%2520Web%2520Flow 下载 org.springframework.webflow-2.3.1 和依赖项 | 并解决异常

关于java - 我需要什么配置和库才能在 jsf 项目中使用 spring security taglibs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13775181/

相关文章:

java - 在 Java 中将元素从一个数组插入到另一个数组

java - 从 try/catch block 中返回变量

java - Spring Boot不会在MySQL中创建表

javascript - 每当您返回使用 javascript 或 jsf 的页面时,如何在 jsp 页面上维护复选框状态,而不将其存储到数据库中

jsf - 单个表单中的 primefaces Accordion 面板 - 仅在打开的选项卡上验证

java - 密码检查成功后加载新网页

java - Maven 与较旧的 Spring Boot 版本的依赖关系

java - 如果用户想再玩一次,如何从arraylist中随机选择并再次循环?

java - org.springframework.dao.DataIntegrityViolationException : Duplicate entry Spring+Hibernate

java - 配置更改无需重新部署