Often when this happens, there are classes that appear in both jars, so you can check your classpath looking for duplicates. Given a class, you can see how often it appears on the classpath:
public void testSomeClassInClassPathOnce() {
String className = SomeClass.class.getName();
String path = className.replace('.', File.separatorChar) + ".class";
Enumeration<URL> urls = ClassLoader.getSystemResources(path);
assertTrue(urls.hasMoreElements());
urls.nextElement();
assertFalse(urls.hasMoreElements());
}
If the old jar has a class that isn't in the new one, then you can use ClassLoader.getSystemResource()
to see if that class is on your classpath.
Note that you need to make sure your JUnit test has all of the production jars in the classpath.