In our WAR We have three JARs that include the class
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager. One jar has an older version than the others.
This does not cause an issue in our dev or staging environments, however in our production environment a version of the class from a different JAR is loaded causing us a
java.lang.NoSuchMethodError on startup. I've taken the exact same WAR that fails in production, and ran it successfully in stage and development.
In Java, what dictates the selection of which jar version of a class is chosen? What would cause that to be different on one box versus another?
You can never find out in which order jars will be loaded by Classloader[you can visualize that by using option
-verbose:class] or modify that. So now that you know the issue that 2 jars have same file then just place the correct jar else its just a luck of draw whether you get error or not.
EDIT: You can also check this question How to find which jars and in what order are loaded by a classloader?