Bug 53356 - Mapping a servlet to the applicatio​n's context root results in IAE
Summary: Mapping a servlet to the applicatio​n's context root results in IAE
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.27
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2012-06-04 19:29 UTC by Violeta Georgieva
Modified: 2012-06-25 17:37 UTC (History)
0 users

test web app (3.92 KB, application/x-zip-compressed)
2012-06-04 19:29 UTC, Violeta Georgieva

Note You need to log in before you can comment on or make changes to this bug.
Description Violeta Georgieva 2012-06-04 19:29:25 UTC
Created attachment 28881 [details]
test web app

I have an application and I want to map my servlet to the application's context root, but I do not want to override the "/" mapping for the "default" servlet.
It is specified in the Servlet spec that there is a "special" url mapping that can be used for such purposes and it is an empty string ("").
I tried several approaches to specify this via web.xml and annotation, unfortunately all of them results in IAE:

Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern>  in servlet mapping
 at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3208)
 at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3183)
 at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1302)
 at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1305)
 at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:855)
 at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:346)

The issue was started as mail thread in the users list - http://marc.info/?t=133883470600003&r=1&w=2

Can you please provide this feature?
Thanks in advance

PP: test application is attached.
Comment 1 Mark Thomas 2012-06-04 20:42:42 UTC
Not fixed yet but as an aside you'll need to use <url-pattern></url-pattern> not <url-pattern>""</url-pattern>
Comment 2 Mark Thomas 2012-06-05 18:20:48 UTC
Thanks for the report. Fixed in trunk and 7.0.x and will be included in 7.0.28 onwards.
Comment 3 Violeta Georgieva 2012-06-25 17:37:04 UTC