How to add a directory to a path to specific Tomcat 7 content?

How to add a directory to the classpath classloader assigned to a specific Tomcat 7 context ?

I want the Java Servlet application to load the properties file external to warfile from a directory in the classpath visible only to this servlet . For example, the servlet context /appAon the host localhostshould load /etc/appA/application.properties(Linux) or D:\configuration\appA\application.properties(Windows), while the servlet context /appBon the same host should not have /etc/appA(Linux) or D:\configuration\appA\its class path.

+4
source share
1 answer

-:

/etc/appA common.loader /conf/catalina.properties.

webapp:

$CATALINA_BASE/conf/Catalina/localhost/appA.xml, <Context>, <Loader> VirtualWebappLoader:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/appA">
    <Loader className="org.apache.catalina.loader.VirtualWebappLoader"
              virtualClasspath="/etc/appA"/>
</Context>

:

VirtualClassLoader

+3

Source: https://habr.com/ru/post/1599152/


All Articles