Reputation: 24069
I'm currently facing severe classpath problems with Jenkins 1.532.2 and Maven 3.0.3. Locally, the classpath order is correct and all JUnit test work. On Jenkins though, the classpath is ordered alphabetically, not like in the pom defined.
Output of mvn dependencies:build-classpath
on Jenkins (partly redacted):
axis/axis/1.4/axis-1.4.jar
axis/axis-wsdl4j/1.5.1/axis-wsdl4j-1.5.1.jar
com/company/ownlibrary.jar
com/microsoft/sqljdbc4/3.0/sqljdbc4-3.0.jar
com/oracle/ojdbc6/11.2.0.1.0/ojdbc6-11.2.0.1.0.jar
commons-codec/commons-codec/1.5/commons-codec-1.5.jar
commons-discovery/commons-discovery/0.2/commons-discovery-0.2.jar
commons-lang/commons-lang/2.4/commons-lang-2.4.jar
commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
junit/junit/4.11/junit-4.11.jar
log4j/log4j/1.2.17/log4j-1.2.17.jar
org/apache/axis/axis-jaxrpc/1.4/axis-jaxrpc-1.4.jar
org/apache/axis/axis-saaj/1.4/axis-saaj-1.4.jar
org/apache/poi/poi/3.8/poi-3.8.jar
org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
org/mockito/mockito-core/1.9.5/mockito-core-1.9.5.jar
org/objenesis/objenesis/1.0/objenesis-1.0.jar
org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar
This is the output of mvn dependencies:build-classpath
locally executed (partly redacted):
com\oracle\ojdbc6\11.2.0.1.0\ojdbc6-11.2.0.1.0.jar
commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar
org\apache\poi\poi\3.8\poi-3.8.jar
commons-codec\commons-codec\1.5\commons-codec-1.5.jar
de\company\xyz.jar
de\company\xyz2.jar
com\company\own.jar
log4j\log4j\1.2.17\log4j-1.2.17.jar
commons-lang\commons-lang\2.4\commons-lang-2.4.jar
com\microsoft\sqljdbc4\3.0\sqljdbc4-3.0.jar
axis\axis\1.4\axis-1.4.jar
org\apache\axis\axis-jaxrpc\1.4\axis-jaxrpc-1.4.jar
org\apache\axis\axis-saaj\1.4\axis-saaj-1.4.jar
axis\axis-wsdl4j\1.5.1\axis-wsdl4j-1.5.1.jar
commons-discovery\commons-discovery\0.2\commons-discovery-0.2.jar
org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar
junit\junit\4.11\junit-4.11.jar
org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar
org\mockito\mockito-core\1.9.5\mockito-core-1.9.5.jar
org\objenesis\objenesis\1.0\objenesis-1.0.jar
I use Maven 3.0.3 so it should use the pom-defined ordering of dependencies.
What can be the source of this problem and how can I solve this?
Additional info: As you can see on the classpath items, I'm building locally on Windows and Jenkins runs on a Linux OS.
New information: The Maven process on Linux also does not work correctly. I tried to build it locally on the machine, on which Jenkins runs, and the result is the same. The classpath is ordered, although I tried Maven 3.0.3 and 3.2.1
Upvotes: 1
Views: 800
Reputation: 24069
Updating Maven to 3.2.1 helped with the sorting classpath, but not the classpath problem. The classpath is not sorted anymore on Jenkins, but the resources are loaded in a false order nonetheless.
Upvotes: 1
Reputation: 11055
IMHO, class path order should not matter. If you have issues, it means you are loading more than one version of the same jar. You should not rely on class path order.
You should understand why it happens and if you cannot avoid it, use the mvn dependency:tree
to figure out where the "bad" jar is coming from, and add an exclude in the dependency that's responsible for it.
I hope this helps.
Upvotes: 1