I would like to know how to upload a WAR file separated from its dependencies.
For example, you upload al the dependecies and leave them in the classpath
then you upload your WAR file without the dependencies packed in it.
When you are testing you servlet this is very useful as you don´t have to upload
a big WAR file with small changes everytime you need to correct something.
The problem is that sometimes it works and some other times it doesn´t.
So is there an official correct way of doing this?
Of course just packing everything into the WAR file does the job.
If your WAR file has dependencies that are outside of it, then you will need to restart Tomcat whenever you update those dependencies: there is no such thing as a CLASSPATH for a WAR file other than what the container builds for you (which will include the stuff in the webapp’s WEB-INF/classes and WEB-INF/lib/*.jar, plus all the libraries guaranteed to be available by the container like servlet.jar, etc.).
Tomcat allows you to use a shared lib directory but that doesn’t auto-reload when libraries are updated, which is likely to be causing the “inconsistent” behavior that you are observing.
The official correct way of doing this is to upload the whole WAR file: that’s what they are for.