java.lang.IllegalArgumentException:过滤器映射必须指定或或
我使用 next web.xml 创建了非常简单的 REST 应用程序:
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
我使用 servlet 3.0 规范和 Tomcat 7.0.23。不幸的是它总是失败:
Caused by: java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
at org.apache.catalina.core.StandardContext.validateFilterMap(StandardContext.java:2995)
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2954)
我不知道问题出在哪里......我在代码中没有使用过滤器,我该如何修复它?
I've created very simple REST app with next web.xml:
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
I'm using servlet 3.0 specification and Tomcat 7.0.23. Unfortunately it fails all time:
Caused by: java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>
at org.apache.catalina.core.StandardContext.validateFilterMap(StandardContext.java:2995)
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2954)
I don't imagine where problem is... I don't use filters in my code, how can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这与 RESTEasy 问题 577 相关。要解决此问题,您需要将
metadata-complete="true"
添加到/WEB-INF/web 的
。
根声明中.xml这样,Tomcat 将假定
/WEB-INF/web.xml
是完整的,并且不会扫描 JAR 以获取web.xml
片段中的其他元数据信息,在这种情况下RESTEasy 显然包含不正确/不完整声明的过滤器。This is related to RESTEasy issue 577. To fix this, you need to add
metadata-complete="true"
to the<web-app>
root declaration of your/WEB-INF/web.xml
.This way Tomcat will assume that the
/WEB-INF/web.xml
is complete and won't scan JARs for additional metadata information inweb.xml
fragments which in case of RESTEasy apparently contain incorrectly/incompletely declared filters.当然,添加 'metadata-complete="true"' 将阻止任何其他 jar 为 web.xml 做出贡献,包括 RichFaces 和 Seam。最好从您的部署中排除有问题的 JAR 文件。就我而言,是 async-http-servlet-3.0-2.3.3.Final.jar 冒犯了。
Of course, adding 'metadata-complete="true"' will block any other jars from contributing to web.xml, including RichFaces and Seam. It is better to exclude the offending JAR file from your deployment. In my case, it was the async-http-servlet-3.0-2.3.3.Final.jar who offended.
这是 Tomcat 7(版本 <7.0.28)中的一个错误,请参阅对类似问题的回复,以及< a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=53354" rel="nofollow noreferrer">链接的 Tomcat 7 bugzilla 票。
It's a bug in Tomcat 7 (version < 7.0.28), see that reply to a similar question, and the linked Tomcat 7 bugzilla ticket.