tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: Issue with WebResource Caching
Date Fri, 18 May 2018 06:23:32 GMT
On 17/05/2018 15:43, Jeremy Collins wrote:


> At this point we're unsure if this is an actual bug in Tomcat or an
> incorrect usage of getResourceAsStream(path) on our part so
> we're looking for advice.

I think it is a bit of both.

ServletContext.getResourceAsStream(path) won't normally return a 
resource that is packaged in a JAR file. The exception to this is if the 
resource is packaged under META-INF/resources as per the 'package static 
resources in a JAR' feature that was added in Servlet 3.0.

It looks to me like META-INF/resources does everything you need it to - 
and will be supported by any Servlet 3.0 compliant container (7.0.x 
onwards in Tomcat's case). I'd look at using it.

ClassLoader.getResourceAsStream(path) is the way to retrieve a resource 
from a JAR but that isn't working in this case.

Tomcat uses the same code for static and class loader resources but it 
is meant to distinguish between the two. However, it looks like there is 
a bug in Tomcat's resource handling that hides this resource once the 
static look-up fails. I need to dig into this some more.

And thanks for the test case. Being able to reproduce this makes 
investigation a whole lot easier.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message