On 01/08/18 08:20, Thorsten Schöning wrote:
> Guten Tag Mark Thomas,
> am Dienstag, 31. Juli 2018 um 19:30 schrieben Sie:
> 
>> Correct.[...]
> 
> But as could have been read in the following paragraph of my mail and
> the SO-link, it doesn't work that way at least in Tomcat 7.0.90 even
> without absolute ordering in web.xml.
> 
>> Enumeration<URL> resources;
>> if (loader == null) {
>>     resources = ClassLoader.getSystemResources(configFile);
>> } else {
>>    resources = loader.getResources(configFile);
>> }
> 
> https://github.com/apache/tomcat/blob/trunk/java/org/apache/catalina/startup/WebappServiceLoader.java#L132
> 
> That code is NOT using "META-INF/services" at the top level of the web> 
> project,

Nor should it. foo.war!/META-INF/services is not a valid location for an
SPI file.

> but "WEB-INF/classes/META-INF/services" instead. That can be
> clearly seen e.g. using Process Monitor.

The correct locations are:
foo.war!/WEB-INF/lib/*.jar!/META-INF/services

which is where Tomcat looks.

Tomcat uses ClassLoader.getResources() which will also pick up
foo.war!/WEB-INF/classes/META-INF/services since the class loader
doesn't differentiate between a resource located at the root of a JAR or
a resource located in at the root of /WEB-INF/classes

There are benefits to this as IDE / Tomcat integrations have a habit of
placing classes in /WEB-INF/classes rather than in JAR file in /WEB-INF/lib

> So is this a bug or needs some configuration or has changed in newer
> versions of Tomcat or whatever?

No bug. No configuration required. No change in newer Tomcat versions.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to