<p>Do anyone know what's the libraries load order based on, in a single folder on Tomcat 8?</p>
<p>Here is my situation:<br />
There is this customer java application deployed on tomcat that, for some reasons, has a class in multiple libraries in the same webapp-shared folder. I know it's wrong, everyone knows that, but this customer refuses to fix this.<br />
We have to deploy this application on kubernetes, so we created a Dockerfile and everything else, and it's working correctly <em>most of the time</em>.<br />
When a pod is deployed on some nodes, it seems that the load order of the libraries is different, and that causes the application to not work properly.</p>
<p>So, basically, what I'm asking is: is there anyone who actually knows what's the load order based on? Is it the filesystem used? Is it the docker overlay? Can it be the LC_COLLATE? Is it actually pseudo random?<br />
These nodes are basically identical and I'm really having a hard time trying to find out what the difference could be.<br />
Thank you.</p>

<p>The only ordering specified by the Servlet Specification is that classes in <code>/WEB-INF/classes</code> have precedence over <code>/WEB-INF/libs/*.jar</code>.</p>
<p>In Tomcat 7 and earlier the order of libraries in the <code>libs</code> depended on the underlying filesystem, so that it would break when you move your web application to a different OS or to a different Java EE server. In Tomcat 8 and later it is random by design. As random as a <code>HashSet</code> is.</p>
<p>See discussion in <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=57129" rel="nofollow noreferrer">Bug 57129</a>. Regarding <code>Resources</code> and <code>PreResources</code> see <a href="https://tomcat.apache.org/tomcat-8.5-doc/config/resources.html" rel="nofollow noreferrer">configuration reference</a>.</p>
