How to add external resources to classpath in Tomcat 8?

Solution Verified - Updated -

Issue

  • How to add external resources to classpath in Tomcat 8?
  • What is replaced by VirtualWebappLoader in Tomcat8?
  • How to configure PreResources element in Tomcat8 server.xml?
  • Is it recommended to configure PreResources element in Tomcat8 server.xml?
  • When configuring the PreResources element as follow in Tomcat server.xml then accessing /docs context will throw HTTP 404 error but configuring the same in $CATALINA_HOME/conf/context.xml will works fine.Why?Is this is a bug?
 <Context path="/docs">
                    <Resources className="org.apache.catalina.webresources.StandardRoot">
                        <PreResources className="org.apache.catalina.webresources.DirResourceSet"
                                      base="/tmp"
                                      internalPath="/"
                                      webAppMount="/WEB-INF/classes"/>
                    </Resources>
</Context>

Environment

  • Red Hat JBoss Web Server (JWS) 3.0
    • Tomcat 8

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.