I have a .war file in Tomcat server. The .war file contains a file that I would like to override. The webapp will load up the file from the classpath.
How can I modify the classpath so that the server will load an another file from the local disk instead? Basically I should add to start the classpath the directory where my replacement file resides. How can I do that?
Unfortunately, Java works on a first-come, first-serve basis. If you have two identical files in two different jars, for example, whichever one appears first in Tomcat's classpath hierarchy will be used. The Tomcat 5.5 documentation talks about the order specifically.
So if you'd like to have one library take precedence over the other, you'll have to make sure that the one receiving precedence appears (alphabetically) before the one you want to be overwritten in
WEB-INF/lib
.(BTW, this is what is infamously known as jar hell)