We're updating the issue view to help you get more done. 

Improve Loading of Jar in Tomcat when Using Resources Mecanism

Description

Hi

I have recently need to Load an SCI (ServletContainerInitializer) with Tomcat using Resource mechanism (this mechanism is used by WarExtraClasspath in Cargo).
So I have put a META-INF/services/file declaring the SCI in jar, and put jar in WEB-INF/lib => in Resource mechanism actually in Cargo this generate this in context.xml file

1 <PostResources className="org.apache.catalina.webresources.JarResourceSet" base="/tmp/my.jar" webAppMount="WEB-INF/classes" />

But this doesn't work because Tomcat see this like a jar content put in WEB-INF/classes folder, so SCI will not be loaded because SCI is load only in WEB-INF/lib.
So the jar must be declare as a virtual Jar in WEB-INF/lib
To do that the context.xml file must be like this :

1 <PostResources className="org.apache.catalina.webresources.FileResourceSet" base="/tmp/my.jar" webAppMount="WEB-INF/lib/my.jar" />

I propose to change the behavior of jar managing in WarExtraClasspath to use this kind of declaration who is a better matching of jar in a web app.
If needed I can add parameter to switch back in WEB-INF/classes mode

Status

Assignee

Thomas Collignon

Reporter

Thomas Collignon

Components

Fix versions

Priority

Medium