Bug 56665

Summary: XML schema validation exception for effective web.xml generated for servlet-mapping with empty url-pattern
Product: Tomcat 7 Reporter: Konstantin Kolinko <knst.kolinko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 7.0.54   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Konstantin Kolinko 2014-06-24 13:23:50 UTC
I am observing this with the current Tomcat 7 (built from revision 1605072)
If the following 3 conditions are met:
1) Server is running in "strict compliance" mode
2) There is a servlet that is mapped to context root using URL pattern "" (empty string) - per Servlet 3.0 mrel spec chapter 12.2 Specification of Mappings

Then whenever Tomcat tries to compile a JSP page, it fails when trying to validate effective merged web.xml against the schema.

To work around the issue I disabled XML validation for this specific context, via <Context xmlValidation="false"/>

1. Add the following mapping at the end of webapps/examples/WEB-INF/web.xml:
        <url-pattern />

2. Configure Tomcat in "strict compliance" mode by adding the following line to conf/catalina.properties:

3. Purge the work/ directory to remove compiled JSPs, if there are any.
4. Start Tomcat

5. Access http://localhost:8080/examples/
The "Request Information Example" page is shown. Thus the empty URL mapping is working correctly.

6. Access a JSP page, http://localhost:8080/examples/jsp/jsp2/el/basic-arithmetic.jsp
Expected: Some arithmetics demo page
Actual: Error 500

HTTP Status 500 - org.apache.jasper.JasperException: XML parsing error on file org.apache.tomcat.util.scan.MergedWebXml: (line 176, col 21)

Stack Trace:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: XML parsing error on file org.apache.tomcat.util.scan.MergedWebXml: (line 176, col 21)
Comment 1 Konstantin Kolinko 2014-06-24 13:27:45 UTC
org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'servlet-mapping' is not complete. One of '{"http://java.sun.com/xml/ns/javaee":url-pattern}' is expected.

Running with <Context logEffectiveWebXml="true"/> to log the generated merged web.xml I can see that an url-pattern element was lost from the generated mapping:

Comment 2 Violeta Georgieva 2014-06-25 14:10:05 UTC
This has been fixed in trunk for 8.0.10 and in 7.0.x for 7.0.55 onwards.