dockerkubernetestomcatfilesystems

Libraries load order on Tomcat 8+ from a single folder


Does anyone know what the library load order is based on in a single folder on Tomcat 8?

Here is my situation:

There is this customer Java application deployed on Tomcat that, for some reason, has a class in multiple libraries in the same web app-shared folder. I know it's wrong; everyone knows that; but this customer refuses to fix this.

We have to deploy this application on Kubernetes, so we created a Dockerfile and everything else, and it's working correctly most of the time.
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.

So, basically, what I'm asking is: is there anyone who actually knows what the load order is based on? Is it the filesystem used? Is it the docker overlay? Can it be the LC_COLLATE? Is it actually pseudo-random?
These nodes are basically identical and I'm really having a hard time trying to find out what the difference could be.


Solution

  • The only ordering specified by the Servlet Specification is that classes in /WEB-INF/classes have precedence over /WEB-INF/libs/*.jar.

    In Tomcat 7 and earlier the order of libraries in the libs 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 HashSet is.

    See discussion in Bug 57129. Regarding Resources and PreResources see configuration reference.