Invalid /admin/*.jsp in filter mapping

完成错误信息

严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhuozhouzyy]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	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(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/zhuozhouzyy]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	... 6 more
Caused by: java.lang.IllegalArgumentException: Invalid  /admin/*.jsp in filter mapping
	at org.apache.catalina.core.StandardContext.validateFilterMap(StandardContext.java:3010)
	at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2959)
	at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1284)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1193)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:783)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:307)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5213)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 6 more

六月 28, 2017 3:35:21 下午 org.apache.catalina.core.ContainerBase startInternal
严重: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	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(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 6 more

六月 28, 2017 3:35:21 下午 org.apache.catalina.startup.Catalina start
严重: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8006]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 11 more

六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol pause
信息: Pausing ProtocolHandler ["http-nio-8081"]
六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol pause
信息: Pausing ProtocolHandler ["ajp-nio-8010"]
六月 28, 2017 3:35:21 下午 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service Catalina
六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["http-nio-8081"]
六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol destroy
严重: Failed to destroy end point associated with ProtocolHandler ["http-nio-8081"]
java.lang.NullPointerException
	at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:316)
	at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:492)
	at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:883)
	at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551)
	at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol destroy
信息: Destroying ProtocolHandler ["ajp-nio-8010"]
六月 28, 2017 3:35:21 下午 org.apache.coyote.AbstractProtocol destroy
严重: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8010"]
java.lang.NullPointerException
	at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:316)
	at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:492)
	at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:883)
	at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551)
	at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879)
	at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

要解决这个问题,知道其发生的原因,就是了解 url-pattern 的规则。

Servlet和filter是J2EE开发中常用的技术,使用方便,配置简单。servlet和filter中的url-pattern有一些文章在里面的,总结了一些东西,以免遇到问题又要浪费时间。 


一、先精确匹配,再路径匹配 (路径匹配的时候,先最长路径匹配,再最短路径匹配),至于扩展名匹配,就是单独于精确匹配和匹配的一类了,以上都找不到servlet,就用默认的servlet,配置为/

二,servlet容器对url的匹配过程: 

当 一个请求发送到servlet容器的时候,容器先会将请求的url减去当前应用上下文的路径作为servlet的映射url,比如我访问的是 http://localhost/test/aaa.html,我的应用上下文是test,容器会将http://localhost/test去掉, 剩下的/aaa.html部分拿来做servlet的映射匹配。这个映射匹配过程是有顺序的,而且当有一个servlet匹配成功以后,就不会去理会剩下 的servlet了(filter不同,后文会提到)。其匹配规则和顺序如下: 

1.     精确路径匹配。例子:比如servletA 的url-pattern为 /test,servletB的url-pattern为 /* ,这个时候,如果我访问的url为http://localhost/test ,这个时候容器就会先进行精确路径匹配,发现/test正好被servletA精确匹配,那么就去调用servletA,也不会去理会其他的 servlet了。 

2.     最长路径匹配。例子:servletA的url-pattern为/test/*,而servletB的url-pattern为/test/a/*,此 时访问http://localhost/test/a时,容器会选择路径最长的servlet来匹配,也就是这里的servletB。 

3.     扩展匹配,如果url最后一段包含扩展,容器将会根据扩展选择合适的servlet。例子:servletA的url-pattern:*.action 

4.     如果前面三条规则都没有找到一个servlet,容器会根据url选择对应的请求资源。如果应用定义了一个default servlet,则容器会将请求丢给default servlet(什么是default servlet?后面会讲)。 

     根据这个规则表,就能很清楚的知道servlet的匹配过程,所以定义servlet的时候也要考虑url-pattern的写法,以免出错。 

      对于filter,不会像servlet那样只匹配一个servlet,因为filter的集合是一个链,所以只会有处理的顺序不同,而不会出现只选择一 个filter。Filter的处理顺序和filter-mapping在web.xml中定义的顺序相同。 
   

三,url-pattern详解 

在web.xml文件中,以下语法用于定义映射: 

l. 以”/’开头和以”/*”结尾的是用来做路径映射的。 

2. 以前缀”*.”开头的是用来做扩展映射的。 

3. “/” 是用来定义default servlet映射的。 

4. 剩下的都是用来定义详细映射的。比如: /aa/bb/cc.action 

所以,为什么定义”/admin/*.jsp”这样一个看起来很正常的匹配会错?因为这个匹配即属于路径映射,也属于扩展映射,导致容器无法判断。

从这个规则来看,它实现的有点弱,不够人性化。

但为什么一定要这样实现,而不支持更高级的匹配规则呢?

==================文档信息===================

版权声明:非商用自由转载-保持署名-注明出处

署名(BY) :testcs_dn(微wx笑)

文章出处:[无知人生,记录点滴](http://blog.csdn.NET/testcs_dn)

你可能感兴趣的:(Invalid /admin/*.jsp in filter mapping)