1

你能为我的问题提供一个解决方案吗?

我与 Apache Shiro 集成,一旦我使用 shiro:hasRole 标签或其他标签,就会抛出异常:

Caused by: java.lang.NoSuchMethodException: org.apache.shiro.web.tags.HasRoleTag.<init>(javax.faces.view.facelets.TagConfig)
    at java.lang.Class.getConstructor0(Class.java:2706)
    at java.lang.Class.getConstructor(Class.java:1657)
    at com.sun.faces.facelets.tag.AbstractTagLibrary$HandlerFactory.createHandler(AbstractTagLibrary.java:187)
    at com.sun.faces.facelets.tag.AbstractTagLibrary.createTagHandler(AbstractTagLibrary.java:678)
    at com.sun.faces.facelets.tag.CompositeTagLibrary.createTagHandler(CompositeTagLibrary.java:184)
    at com.sun.faces.facelets.compiler.TagUnit.createFaceletHandler(TagUnit.java:120)
    at com.sun.faces.facelets.compiler.TextUnit.createFaceletHandler(TextUnit.java:117)
    at com.sun.faces.facelets.compiler.CompilationUnit.getNextFaceletHandler(CompilationUnit.java:115)
    at com.sun.faces.facelets.compiler.TagUnit.getNextHandler(TagUnit.java:124)
    at com.sun.faces.facelets.tag.AbstractTagLibrary$ComponentConfigWrapper.getNextHandler(AbstractTagLibrary.java:230)
    at javax.faces.view.facelets.TagHandler.<init>(TagHandler.java:116)
    at javax.faces.view.facelets.MetaTagHandler.<init>(MetaTagHandler.java:105)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.<init>(DelegatingMetaTagHandler.java:69)
    at javax.faces.view.facelets.ComponentHandler.<init>(ComponentHandler.java:128)
    at com.sun.faces.facelets.tag.jsf.html.HtmlComponentHandler.<init>(HtmlComponentHandler.java:75)
    at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.createHandler(AbstractTagLibrary.java:306)
    at com.sun.faces.facelets.tag.AbstractTagLibrary.createTagHandler(AbstractTagLibrary.java:678)
    at com.sun.faces.facelets.tag.CompositeTagLibrary.createTagHandler(CompositeTagLibrary.java:184)
    at com.sun.faces.facelets.compiler.TagUnit.createFaceletHandler(TagUnit.java:120)
    at com.sun.faces.facelets.compiler.TextUnit.createFaceletHandler(TextUnit.java:117)
    at com.sun.faces.facelets.compiler.CompilationUnit.getNextFaceletHandler(CompilationUnit.java:115)
    at com.sun.faces.facelets.compiler.TagUnit.getNextHandler(TagUnit.java:124)
    at com.sun.faces.facelets.tag.AbstractTagLibrary$ComponentConfigWrapper.getNextHandler(AbstractTagLibrary.java:230)
    at javax.faces.view.facelets.TagHandler.<init>(TagHandler.java:116)
    at javax.faces.view.facelets.MetaTagHandler.<init>(MetaTagHandler.java:105)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.<init>(DelegatingMetaTagHandler.java:69)
    at javax.faces.view.facelets.ComponentHandler.<init>(ComponentHandler.java:128)
    at com.sun.faces.facelets.tag.jsf.html.HtmlComponentHandler.<init>(HtmlComponentHandler.java:75)
    at sun.reflect.GeneratedConstructorAccessor19.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.createHandler(AbstractTagLibrary.java:306)

请注意,我有一个正确的 shiro 配置,其中应用了 shiro 安全性并保护了资源,其中用户必须经过身份验证和授权才能访问应用程序资源。

但是一旦我尝试涉及 shiro 安全标签,就会看到异常。

我打开了诸如 HasRoleTag 之类的 shiro java 标签,实际上没有构造函数将实例javax.faces.view.facelets.TagConfig 作为参数!

你能帮我解决这个问题吗?

谢谢。

4

1 回答 1

1

从 1.2 版开始,Shiro 不附带 JSF 支持。您正在查看的标记是 JSP 标记。Deluan Quintão 为 shiro 编写了一组 JSF facelet 标签。你可以在这里阅读他关于使用它们的帖子:http: //techbeats.deluan.com/apache-shiro-tags-for-jsffacelets

请注意,他的工作将从 1.3 开始正式并入 Shiro。(确实,已经在后备箱里了)

于 2012-06-11T15:23:06.507 回答