<shiro:hasrole .. =“”>标签不起作用导致NoSuchMethodException异常</shiro:hasrole>

时间:2012-06-10 14:57:10

标签: jsf-2 tags shiro

你能帮我解决一下我的问题,

我与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的实例 作为参数!

你能帮我解决一下这个问题。

感谢。

1 个答案:

答案 0 :(得分:1)

从版本1.2开始,Shiro不提供JSF支持。您正在查看的标记是JSP标记。 DeluanQuintão为shiro编写了一组JSF facelet标签。您可以在此处阅读他的帖子:http://techbeats.deluan.com/apache-shiro-tags-for-jsffacelets

请注意,他的作品将于1.3开始正式并入Shiro。 (事实上​​,它已经在主干中)