Michael Landes Michael Landes - 1 year ago 263
Java Question

Adding external resources to class-path in Tomcat 8

I have a Tomcat application which needs to reference some properties files that are external to the app. Generally these are stored on a local machine at a specific place like


In Tomcat 7 this was achievable by placing a
file inside of
which used a
to essentially add this location to the application classpath as follows:

<Loader className="org.apache.catalina.loader.VirtaulWebappLoader"
searchVirtualFirst="true" />

How do I achieve this same thing in Tomcat 8?

Answer Source

There is a section about this in the Tomcat 8 migration guide which will direct you to use a resources configuration

In particular, you will be creating a WebResourceRoot object which contains the following text in its description.

VirtualWebappLoader - Replaced by Pre- and Post-Resources mapped to WEB-INF/lib and WEB-INF/classes

Your new context.xml will look something like the following:

    <Resources className="org.apache.catalina.webresources.StandardRoot">
        <PreResources className="org.apache.catalina.webresources.DirResourceSet"
            webAppMount="/WEB-INF/classes" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download