Apache Shiro无法启动Filter - org.apache.shiro.web.servlet.AbstractFilter

时间:2015-08-24 00:21:39

标签: apache shiro

我正在尝试使用JDK 8在Wildfly 9.0.1上的简单Web应用程序上配置Shiro。

我在WEB-INF / lib

中有以下jar

公地BeanUtils的-1.8.3.jar

四郎核-1.2.4.jar

四郎的web-1.2.4.jar

SLF4J-API-1.6.4.jar

我还有两个网页 - index.html和login.jsp。我在WEB-INF /文件夹中添加了shiro.ini和web.xml。 shiro.ini的内容是:

<?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">  
  <display-name>SampleProject</display-name>  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
    <listener>
        <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    </listener>  
     <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
          <init-param>
                <param-name>config</param-name>
                <param-value>shiro.ini</param-value>
            </init-param> 
    </filter>    
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>/*</url-pattern> 
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>   
</web-app>

web.xml内容为:

Context Path:/SampleProject
Servlet Path:/index.html
Path Info:null
Query String:null
Stack Trace
2015-08-23 16:03:58,910 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) started in 3641ms - Started 551 of 754 services (268 services are lazy, passive or on-demand)
2015-08-23 16:04:11,895 ERROR [org.apache.shiro.web.servlet.AbstractFilter] (default task-2) Unable to start Filter: [Line argument must contain a key and a value.  Only one string token was found.].: java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
    at org.apache.shiro.config.Ini$Section.splitKeyValue(Ini.java:542)
    at org.apache.shiro.config.Ini$Section.toMapProps(Ini.java:567)
    at org.apache.shiro.config.Ini$Section.<init>(Ini.java:464)
    at org.apache.shiro.config.Ini$Section.<init>(Ini.java:445)
    at org.apache.shiro.config.Ini.addSection(Ini.java:302)
    at org.apache.shiro.config.Ini.load(Ini.java:351)
    at org.apache.shiro.config.Ini.load(Ini.java:254)
    at org.apache.shiro.web.servlet.IniShiroFilter.convertConfigToIni(IniShiroFilter.java:295)
    at org.apache.shiro.web.servlet.IniShiroFilter.loadIniFromConfig(IniShiroFilter.java:236)
    at org.apache.shiro.web.servlet.IniShiroFilter.configure(IniShiroFilter.java:205)
    at org.apache.shiro.web.servlet.IniShiroFilter.init(IniShiroFilter.java:190)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.onFilterConfigSet(AbstractShiroFilter.java:152)
    at org.apache.shiro.web.servlet.AbstractFilter.init(AbstractFilter.java:97)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111)
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:84)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:97)
    at io.undertow.servlet.core.ManagedFilter.createFilter(ManagedFilter.java:79)
    at io.undertow.servlet.core.ManagedFilter.getFilter(ManagedFilter.java:65)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

2015-08-23 16:04:11,897 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /SampleProject/: javax.servlet.ServletException: java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
    at org.apache.shiro.web.servlet.AbstractFilter.init(AbstractFilter.java:105)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111)
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:84)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:97)
    at io.undertow.servlet.core.ManagedFilter.createFilter(ManagedFilter.java:79)
    at io.undertow.servlet.core.ManagedFilter.getFilter(ManagedFilter.java:65)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
    at org.apache.shiro.config.Ini$Section.splitKeyValue(Ini.java:542)
    ...

但是,一旦我尝试访问该网页http://localhost:8080/SampleProject/index.htmlhttp://localhost:8080/SampleProject/,我就会收到以下错误:

SEVERE: Exception starting filter shiroFilter
javax.servlet.ServletException: java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
    at org.apache.shiro.web.servlet.AbstractFilter.init(AbstractFilter.java:105)
    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4574)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5193)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Line argument must contain a key and a value.  Only one string token was found.
    at org.apache.shiro.config.Ini$Section.splitKeyValue(Ini.java:542)
    at org.apache.shiro.config.Ini$Section.toMapProps(Ini.java:567)
    at org.apache.shiro.config.Ini$Section.<init>(Ini.java:464)
    at org.apache.shiro.config.Ini$Section.<init>(Ini.java:445)
    at org.apache.shiro.config.Ini.addSection(Ini.java:302)
    at org.apache.shiro.config.Ini.load(Ini.java:351)
    at org.apache.shiro.config.Ini.load(Ini.java:254)
    at org.apache.shiro.web.servlet.IniShiroFilter.convertConfigToIni(IniShiroFilter.java:295)
    at org.apache.shiro.web.servlet.IniShiroFilter.loadIniFromConfig(IniShiroFilter.java:236)
    at org.apache.shiro.web.servlet.IniShiroFilter.configure(IniShiroFilter.java:205)
    at org.apache.shiro.web.servlet.IniShiroFilter.init(IniShiroFilter.java:190)
    at org.apache.shiro.web.servlet.AbstractShiroFilter.onFilterConfigSet(AbstractShiroFilter.java:152)
    at org.apache.shiro.web.servlet.AbstractFilter.init(AbstractFilter.java:97)
    ... 12 more

我已将项目移至tomcat 8.0.24并出现类似错误:

{{1}}

有人可以告诉我这里有什么问题吗?

1 个答案:

答案 0 :(得分:0)

我不知道你需要为IniShiroFilter使用什么。但我用你的web.xml配置测试了我的shiro应用程序,我遇到了同样的问题。从

更改您的web.xml
 <filter>
    <filter-name>shiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
      <init-param>
            <param-name>config</param-name>
            <param-value>shiro.ini</param-value>
        </init-param> 
</filter>

<filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>