Bug 43338 - Setting '*' as the servlet-name in filter-mapping causes IllegalArgumentException.
Summary: Setting '*' as the servlet-name in filter-mapping causes IllegalArgumentExcep...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 6.0.14
Hardware: All All
: P1 normal (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 42683 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-10 03:45 UTC by Keiichi Fujino
Modified: 2008-11-03 06:29 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Keiichi Fujino 2007-09-10 03:45:11 UTC
SRV 6.2.5 says supporting for '*' as the servlet-name in filter-mapping.
I set following filter-mapping.
    <filter-mapping>
        <filter-name>SampleFilter</filter-name>
        <servlet-name>*</servlet-name>
    </filter-mapping>

However, InvocationTargetException occurred in Digester. 
It is as follows.

Sep 10, 2007 7:16:56 PM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.apache.tomcat.util.IntrospectionUtils.callMethod1
(IntrospectionUtils.java:899)
	at org.apache.tomcat.util.digester.SetNextRule.end
(SetNextRule.java:193)
	at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
	at org.apache.tomcat.util.digester.Digester.endElement
(Digester.java:1058)
	omit...
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.IllegalArgumentException: Filter mapping must specify 
either a <url-pattern> or a <servlet-name>
	at org.apache.catalina.core.StandardContext.addFilterMap
(StandardContext.java:2160)
	... 44 more
   omit...


I made a StandardContext's patch.

Index:/tomcat6-trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- /tomcat6-trunk/java/org/apache/catalina/core/StandardContext.java
	(revision 574195)
+++ /tomcat6-trunk/java/org/apache/catalina/core/StandardContext.java
	(working copy)
@@ -2156,7 +2156,9 @@
         if (findFilterDef(filterName) == null)
             throw new IllegalArgumentException
                 (sm.getString("standardContext.filterMap.name", filterName));
-        if ((servletNames.length == 0) && (urlPatterns.length == 0))
+        if (!filterMap.getMatchAllServletNames() && 
+        		!filterMap.getMatchAllUrlPatterns() && 
+                (servletNames.length == 0) && (urlPatterns.length == 0))
             throw new IllegalArgumentException
                 (sm.getString("standardContext.filterMap.either"));
         // FIXME: Older spec revisions may still check this

I made a StandardContext's patch.

Regards.
Comment 1 Peter Rossbach 2007-09-14 23:53:05 UTC
OK!

I check you fix later today

Peter
Comment 2 Peter Rossbach 2007-09-15 00:56:16 UTC
Many thanks to report this bug
Peter
Comment 3 Mark Thomas 2008-11-03 06:29:12 UTC
*** Bug 42683 has been marked as a duplicate of this bug. ***