<p>I have a war file that I deployed with Tomcat.<br />
I have a Dockerfile and at the end I build a kubernetes pod.</p>
<p>The problem is that if my property files from my app do exist in the path: <code>/usr/local/tomcat/webapps/myapp/WEB-INF/classes/config/</code> and not in path <code>/usr/local/tomcat/webapps/myapp/WEB-INF/classes/</code>, so the application does not start.</p>
<p>Is it possible to set a classpath in Tomcat to point to a specific folder?<br />
For example, I want to set classpath like: <code>/usr/local/tomcat/webapps/myapp/WEB-INF/classes/config/</code>.<br />
I don't want to have duplicate property files.</p>

<p>As <a href="https://stackoverflow.com/a/2161583/6309">mentioned here</a>:</p>
<blockquote>
<p><code>foo.properties</code> is supposed to be placed in one of the roots which are covered by the default classpath of a webapp, e.g. webapp's <code>/WEB-INF/lib</code> and /WEB-INF/classes, server's /lib, or JDK/JRE's /lib.</p>
<ul>
<li>If the properties file is webapp-specific, best is to place it in <code>/WEB-INF/classes</code>.</li>
<li>If you're developing a standard WAR project in an IDE, drop it in <code>src</code> folder (the project's source folder).</li>
<li>If you're using a Maven project, drop it in <code>/main/resources</code> folder.</li>
</ul>
<p>You can alternatively also put it somewhere outside the default classpath and add its path to the classpath of the appserver.<br />
<strong>In for example Tomcat you can configure it as <code>shared.loader</code> property of <code>Tomcat/conf/catalina.properties</code>.</strong></p>
</blockquote>
<p><a href="https://gist.github.com/ghusta/12b50687a39bd02a88680df450a840f4" rel="nofollow noreferrer">Example</a>:</p>
<pre><code>FROM tomcat:8.5-jre8
 
# $CATALINA_HOME is defined in tomcat image
ADD target/my-webapp*.war $CATALINA_HOME/webapps/my-webapp.war
 
# Application config
RUN mkdir $CATALINA_HOME/app_conf/
ADD src/main/config/test.properties $CATALINA_HOME/app_conf/
 
# Modify property 'shared.loader' in catalina.properties
RUN sed -i -e 's/^shared.loader=$/shared.loader=&quot;${catalina.base} \/ app_conf&quot;/' $CATALINA_HOME/conf/catalina.properties
</code></pre>
