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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content