Bug 53354 - <filter-mapping> doesn't find the @WebFilter(filterName)
Summary: <filter-mapping> doesn't find the @WebFilter(filterName)
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Servlet & JSP API (show other bugs)
Version: 7.0.27
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-06-03 19:16 UTC by balusc
Modified: 2012-06-03 21:18 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description balusc 2012-06-03 19:16:25 UTC
As it's not possible to specify the invocation order in a @WebFilter, users are forced to explicitly specify <filter-mapping> in web.xml. This works in combination with a @WebFilter(filterName) in Glassfish and JBoss AS as follows:

public class Filter1 implements Filter {}

public class Filter2 implements Filter {}



However it fails in Tomcat 7.0.27 with the following confusing exception (the <url-pattern> *is* been set)

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:3009)
	at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:2968)
	at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1207)
	at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1294)
	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	... 7 more
Comment 1 Mark Thomas 2012-06-03 21:18:50 UTC
Thanks for the report. Fixed in trunk and 7.0.x and will be included in 7.0.28 onwards.