It says here that the common classloader is visible to all web application. So what is the difference between having a JAR file within the WEB-INF/lib
folder of my war
application and having the same JAR file within Tomcat's lib
folder?
This JAR is a provider for a Java SPI that I created. When I have it under WEB-INF/lib
, everything works perfectly. But if I try to put this JAR under Tomcat's lib
folder (or under shared/lib
after configuring it in catalina.properties
) I get errors. The second option is better for me because I need total decoupling of my application and the provider.
The error I get is a ClassNotFoundException
for the interface that represents my service (which the JAR implements). This interface is in a third project, which is a dependency for my war
application.
The tomcat/lib
directory should be used for shared libraries for the whole web server and WEB-INF/lib
only for one web application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With