On 16/04/2019 20:32, Christopher Schultz wrote:
> Akram,
> 
> On 4/16/19 12:41, Akram Hussain wrote:
>> I have gone through it, But it was not clear to me.
> 
>> If an example is provided, how to pass resources to
>> SharedClassLoader, it could be helpful.
> 
> If you configure something like this in your META-INF/context.xml:
> 
> <Resources>
>   <PostResources webAppMount="/WEB-INF/classes"
> base="/path/to/your/shared/libraries"
> className="org.apache.catalina.webresources.DirResourceSet" />
> </Resources>
> 
> That should allow your application to load JAR files from your
> /path/to/your/shared/libraries directory.

The OP is trying to load JARs so the /path/to/your/shared/libraries
directory needs to be mounted at WEB-INF/lib, not WEB-INF/classes.

We (OK I since I wrote this stuff) should probably have better
documented which implementation to pick.

You pick the implementation based on where the files you want to insert
are located.

If you want to insert a single file, use FileResourceSet
If you want to insert a directory tree, use DirResourceSet
If you want to insert files from inside an archive (JAR) then use a
JarResourceSet.

Note: Using a JarResourceSet effectively unpacks the archive as far as
Tomcat is concerned so Tomcat sees directories and files, not a single
JAR file.

In this case you have a directory of JAR files so you want a DirResourceSet.

Assuming you want those JAR files to be treated as if they were placed
in WEB-INF/lib then you want:

<Resources>
  <PostResources
      webAppMount="/WEB-INF/lib"
      base="/path/to/your/shared/libraries"
      className="org.apache.catalina.webresources.DirResourceSet"
  />
</Resources>

That has the same effect as copying the entire contents of
/path/to/your/shared/libraries to WEB-INF/lib.

If you want this to apply to every web application you deploy then add
the above to global context.xml in CATALINA_BASE/conf/context.xml

Mark

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

Reply via email to