Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Is your classpath backwards?

Read this document if you think Maven is putting your classpath in the wrong order.

Two bugs canceled each other out

Take a look at http://jira.codehaus.org/browse/MNG-3118. That bug was fixed in Maven 2.0.8 and called out in the release announcement as a backwards compatibility risk:

http://www.mail-archive.com/announce@apache.org/msg00432.html

As noted in the comments to MNG-3118, Surefire 2.3 had a bizarre classpath ordering bug that made the test classpath appear to be correct (test-classes first) under Maven 2.0.7 for some users with large classpaths:

http://jira.codehaus.org/browse/SUREFIRE-61

SUREFIRE-61 was fixed in Surefire 2.3.1. Notably, it would make the "Test Classpath" output in -X look correct, while secretly under the hood it would munge the classpath incorrectly!

As a result, for at least one project here at my work, we've seen:

Maven 2.0.7 + Surefire 2.3: test-classes before classes
Maven 2.0.8 + Surefire 2.3: classes before test-classes
Maven 2.0.7 + Surefire 2.3.1 or higher: classes before test-classes
Maven 2.0.8 + Surefire 2.3.1 or higher: test-classes before classes

Benjamin checked in a classpath ordering test in the Surefire trunk that we now run with every release. It's currently passing in Surefire 2.4.2 and Maven 2.0.8, and failing with Maven 2.0.7.

Still having problems?

Read this page, which explains how Surefire launches your tests. Classloading and Forking under Maven Surefire

Also, take a look at this Nabble discussion. (Mostly redundant, but it couldn't hurt.) http://www.nabble.com/Surefire-2.4.1-classpath-order-td15498825s177.html