Bug 54262 - An empty <absolute-ordering /> should turn off all web-fragments
An empty <absolute-ordering /> should turn off all web-fragments
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
PC Linux
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2012-12-07 22:00 UTC by Rossen Stoyanchev
Modified: 2014-06-19 09:18 UTC (History)
0 users

resources1.jar (16.01 KB, application/octet-stream)
2012-12-09 20:27 UTC, Konstantin Kolinko
Patch proposal (1.36 KB, patch)
2013-01-04 09:34 UTC, Violeta Georgieva
Details | Diff
Test case (5.20 KB, patch)
2013-01-04 09:34 UTC, Violeta Georgieva
Details | Diff
resources.jar (15.68 KB, application/java-archive)
2013-01-04 09:42 UTC, Violeta Georgieva

Note You need to log in before you can comment on or make changes to this bug.
Description Rossen Stoyanchev 2012-12-07 22:00:09 UTC
The use of an <absolute-ordering> element does disable ServletContainerInitializer classpath scanning as discussed also in issue 53619. However, it does seem to require having at least one web-fragment name to be listed. In other words I would this:

<absolute-ordering />

To turn off all web-fragments since none are named. A workaround is to list a web-fragment even if it doesn't exist but that shouldn't be necessary.
Comment 1 Konstantin Kolinko 2012-12-09 20:27:10 UTC
Created attachment 29736 [details]


Steps to reproduce with 7.0.34:
1. Download attached resources1.jar and put it into webapps/examples/WEB-INF/lib

The file is based on test/webapp-3.0-fragments/WEB-INF/lib/resources.jar from Tomcat sources. I
a) removed all resources except "resourceA.jsp" and
b) declared an instance of HelloWorldServlet in web-fragment.xml.

2. Edit webapps/examples/WEB-INF/web.xml:
a) change metadata-complete attribute s/true/false/
b) add <absolute-ordering />

3. Start Tomcat.
4. Actual result: The following two URLs work:
[1] http://localhost:8080/examples/resourceA.jsp
[2] http://localhost:8080/examples/resources1/HelloWorldExample

Expected result: [2] should return 404 as web-fragment.xml should be ignored and the servlet mapping declared there should be ignored.

<quote from="Servet Spec 3.0 Rev a - page #67 (89/230)">
1.d. (..) If the
 <absolute-ordering> element does not contain an <others/> element,
 any web-fragment not specifically mentioned within <name /> elements
 MUST be ignored. (...)

Regarding [1], I do not see any specific reference that such exclusion affects static resources in META-INF/resources. Thus I think that the expected behaviour of [1] is to display resourcesA.jsp page. 7.0.34 behaves correctly here.
Comment 2 Violeta Georgieva 2013-01-03 18:02:02 UTC

I'm going to work on this.

Comment 3 Violeta Georgieva 2013-01-04 09:34:10 UTC
Created attachment 29811 [details]
Patch proposal
Comment 4 Violeta Georgieva 2013-01-04 09:34:52 UTC
Created attachment 29812 [details]
Test case
Comment 5 Violeta Georgieva 2013-01-04 09:36:40 UTC
Please find attached a patch proposal and a test case for it.

Any comments will be appreciated.

Comment 6 Violeta Georgieva 2013-01-04 09:42:15 UTC
Created attachment 29813 [details]

resources.jar should be placed in <TC7-Trunk>/test/webapp-3.0-fragments-empty-absolute-ordering/WEB-INF/lib
Comment 7 Mark Thomas 2013-01-07 18:50:06 UTC
Thanks for the patch. It has been applied - with some minor changes to trunk and 7.0.x and will be included in 7.0.35 onwards.
Comment 8 Lucas Ventura Carro 2014-06-19 09:18:32 UTC
And what about {tomcat.dist}/lib dir? Because those services are loaded anyway.

Debugging and watching the code of "WebappServiceLoader" and a google search with "containerSciFilter", I see that I can use a Pattern to exclude that classes. Is the only way?