Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>

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?

like image 876
Konstantin Kudryavtsev Avatar asked Dec 20 '11 20:12

Konstantin Kudryavtsev


1 Answers

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.

<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0" metadata-complete="true">

    <!-- Config here. -->

</web-app>

This way Tomcat will assume that the /WEB-INF/web.xml is complete and won't scan JARs for additional metadata information in web.xml fragments which in case of RESTEasy apparently contain incorrectly/incompletely declared filters.

like image 142
BalusC Avatar answered Sep 27 '22 19:09

BalusC