RE: Surefire 2.4.1 classpath order
Hi, I think I had the same problem (the wrong resource was loaded). may solution was to add an explicit version to the SureFire-Plugin configuration: ... version2.4.3/version ... See http://www.nabble.com/%22mvn-test%22-uses-wrong-resources-to18219384.html http://www.nabble.com/%22mvn-test%22-uses-wrong-resources-to18219384.html Cheers Markus -- View this message in context: http://www.nabble.com/Surefire-2.4.1-classpath-order-tp15498825p18235397.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
I took a copy of the project POM and put it in the surefire-integration-tests directory. The tests failed. I then trawled through the project POM and then its parent POM commenting out plugins, reporting, dependencies, and other bits until the test passed. The thing that was causing the test to fail was that in the parent POM: defaultGoalpackage/defaultGoal directorytarget/directory finalName${pom.artifactId}-${pom.version}/finalName sourceDirectory${basedir}/src/main/java/sourceDirectory testSourceDirectory${basedir}/src/test/java/testSourceDirectory testOutputDirectory${basedir}/target/test-classes/testOutputDirectory outputDirectory${basedir}/target/classes/outputDirectory Changing just testOutputDirectory to testOutputDirectorytarget/test-classes/testOutputDirectory Made the tests pass. I've no idea why. Do you want me to raise this as a bug? Ben This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions expressed are those of the author. If you are not the intended recipient, please be advised that any use, dissemination, printing or copying of this email is strictly prohibited. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
Ben Lidgey wrote: Made the tests pass. I've no idea why. Do you want me to raise this as a bug? Yes... nice work! That sounds like a Core bug and not a Surefire bug, so file it against Maven 2 (MNG) in JIRA. Thanks! -Dan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
-Original Message- From: Dan Fabulich [mailto:[EMAIL PROTECTED] Sent: 18 February 2008 22:23 To: Maven Users List Subject: RE: Surefire 2.4.1 classpath order [snip] Looks like we'll need to try some more debugging. :-) 1) If you run mvn -X you'll see lots of useful debugging information, including the command line we used to launch Surefire. It looks something like this: Forking command line: cmd.exe /X /C 'C:\jdk1.5.0_12\jre\bin\java -jar C:\DOCUME~1\dan\LOCALS~1\Temp\surefirebooter61534.jar C:\DOCUME~1\dan\LOCALS~1\Temp\surefire61532tmp C:\DOCUME~1\dan\LOCALS~1\Temp\surefire61533tmp' You may notice that none of your jars appear on this list; that's by design. Go take a look at the jar file and you'll see that it's a manifest-only jar; it contains only a META-INF/MANIFEST.MF file, specifying a Main-Class and a Class-Path to run the code. Make sure that the manifest looks correct and that the jars/dirs appear in the correct order. I get Forking command line: cmd.exe /X /C 'c:\Program Files\Java\jdk1.5.0_14\jre\bin\java -jar c:\DOCUME~1\benl\LOCALS~1\Temp\surefirebooter53271.jar c:\DOCUME~1\benl\LOCALS~1\Temp\surefire53269tmp c:\DOCUME~1\benl\LOCALS~1\Temp\surefire53270tmp' The MANIFEST.MF in the jar shows: Class-Path: file:/C:/Documents%20and%20Settings/benl/.m2/repository/org/apache/maven/surefire/surefirebooter/2.4.1/surefire-booter-2.4.1.jar file:/C:/Documents%20and%20Settings/benl/.m2/repository/org/apache/maven/surefire/surefire-api/2.4.1/surefire-api-2.4.1.jar file:/C:/Documents%20and%20Settings/benl/.m2/repository/junit/junit/4.2/junit-4.2.jar [snip] file:/c:/Development/Projects/Inuk/MyProject/target/classes/ file:/c:/Development/Projects/Inuk/MyProject/target/test-classes/ Main-Class: org.apache.maven.surefire.booter.SurefireBooter And in one of the tmp files included classPathUrl.41=c\:\\Development\\Projects\\Inuk\\MyProject\\target\\test-classes classPathUrl.40=c\:\\Development\\Projects\\Inuk\\MyProject\\target\\classes Which when ordered in ascending order would put target/classes before target/test-classes The effective-pom shows plugin artifactIdmaven-surefire-plugin/artifactId version2.4.1/version configuration redirectTestOutputToFiletrue/redirectTestOutputToFile childDelegationtrue/childDelegation systemProperties property namelog4j.configuration/name valuelog4j.xml/value /property /systemProperties /configuration /plugin Weird. Ben This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions expressed are those of the author. If you are not the intended recipient, please be advised that any use, dissemination, printing or copying of this email is strictly prohibited. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
From: Dan Fabulich [mailto:[EMAIL PROTECTED] 2) Try pulling down our classpath-order test project here: http://svn.apache.org/repos/asf/maven/surefire/trunk/surefire- integration-tests/src/test/resources/classpath-order http://tinyurl.com/3csqca Run mvn test and confirm that you see the same thing I do in classpath-order/target/surefire-reports/TEST-it.BasicTest.xml. I get test-classes first, classes second, and then a whole bunch of jars. If the classpath order is incorrect, the test should fail. Well, no need to panic as the classpath order test passed. Now I need to trawl through our (effective) pom for the project that was failing and see what the classpath is and if anything else is mucking about with the classpath. I'll report on any relevant findings. Ben This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions expressed are those of the author. If you are not the intended recipient, please be advised that any use, dissemination, printing or copying of this email is strictly prohibited. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
-Original Message- From: Dan Fabulich [mailto:[EMAIL PROTECTED] Sent: 15 February 2008 22:52 To: Maven Users List Subject: Re: Surefire 2.4.1 classpath order Ben Lidgey wrote: We are running tests using Surefire 2.4.1 and Maven 2.0.8. [...] [snip] I'm not 100% certain you're using the software you think you're using; here's some debugging/analysis tips. Thanks for the tips. I've gone through the steps below. 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/[EMAIL PROTECTED]/msg00432.html As noted in 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! Doing mvn help:effective-pom showed plugin artifactIdmaven-surefire-plugin/artifactId version2.4.1/version configuration redirectTestOutputToFiletrue/redirectTestOutputToFile childDelegationtrue/childDelegation systemProperties property namelog4j.configuration/name valuelog4j.xml/value /property /systemProperties /configuration /plugin 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 And mvn --version shows $ mvn --version Maven version: 2.0.8 Java version: 1.5.0_14 OS name: windows xp version: 5.1 arch: x86 Family: windows Finally, note that your real classpath is being output in your target/surefire-reports/*.xml files as the surefire.test.classpath property; that may be useful for debugging purposes. The surefire-reports/*.xm files showed property value= C:\Documents and Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar; [more jars] c:\Development\Projects\Inuk\Inuk\ResidentialFramework\BroadbandGateway\target\classes; c:\Development\Projects\Inuk\Inuk\ResidentialFramework\BroadbandGateway\target\test-classes; name=surefire.test.class.path/ With target/classes before targe/test-classes. So, to summarise: Maven 2.0.8, Surefire 2.4.1, target/classes before target/test-classes This is reinforced as the test is failing because the src/main/resources properties file does not have an entry whereas the src/test/resources properties file does, and the test fails as it cannot find that entry (therefore is looking at the one from src/main/resources). Ben This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions expressed are those of the author. If you are not the intended recipient, please be advised that any use, dissemination, printing or copying of this email is strictly prohibited. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Surefire 2.4.1 classpath order
Ben Lidgey wrote: property value= C:\Documents and Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar; [more jars] c:\Development\Projects\Inuk\Inuk\ResidentialFramework\BroadbandGateway\target\classes; c:\Development\Projects\Inuk\Inuk\ResidentialFramework\BroadbandGateway\target\test-classes; name=surefire.test.class.path/ With target/classes before targe/test-classes. This is the reverse order from what it's supposed to be. Not only are test-classes supposed to appear before classes, but both of those are supposed to appear before your dependency jars. Looks like we'll need to try some more debugging. :-) 1) If you run mvn -X you'll see lots of useful debugging information, including the command line we used to launch Surefire. It looks something like this: Forking command line: cmd.exe /X /C 'C:\jdk1.5.0_12\jre\bin\java -jar C:\DOCUME~1\dan\LOCALS~1\Temp\surefirebooter61534.jar C:\DOCUME~1\dan\LOCALS~1\Temp\surefire61532tmp C:\DOCUME~1\dan\LOCALS~1\Temp\surefire61533tmp' You may notice that none of your jars appear on this list; that's by design. Go take a look at the jar file and you'll see that it's a manifest-only jar; it contains only a META-INF/MANIFEST.MF file, specifying a Main-Class and a Class-Path to run the code. Make sure that the manifest looks correct and that the jars/dirs appear in the correct order. 2) Try pulling down our classpath-order test project here: http://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-integration-tests/src/test/resources/classpath-order http://tinyurl.com/3csqca Run mvn test and confirm that you see the same thing I do in classpath-order/target/surefire-reports/TEST-it.BasicTest.xml. I get test-classes first, classes second, and then a whole bunch of jars. If the classpath order is incorrect, the test should fail. Hopefully, classpath-order will pass on your machine. If that's the case, then the next thing to do will be to investigate what's different between your Inuk projects and our classpath-order test. If classpath-order doesn't work on your machine, then I'll be surprised; I'm not exactly certain how to investigate that. You could try filing a bug in that case and attaching debugging information for the classpath-order test. To debug, we'd want: -X logs, a copy of your surefirebooter#.jar, and the two surefire#tmp files that are passed in as arguments. Good luck! -Dan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Surefire 2.4.1 classpath order
Dan - Do you know if that bug was introduced in 2.0.7 (or some other earlier release)? My team is using 2.0.4 and we encountered a problem with the classpath ordering recently that caused builds to that were previously working to suddenly start failing. Thanks, Ken On 2/15/08, Dan Fabulich [EMAIL PROTECTED] wrote: Ben Lidgey wrote: We are running tests using Surefire 2.4.1 and Maven 2.0.8. [...] Looking at the debug output shows: [DEBUG] Test Classpath : [DEBUG] C:\Documents and Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar [more jars] [DEBUG] c:\Development\Projects\MyProject\target\classes [DEBUG] c:\Development\Projects\MyProject\target\test-classes Which would explain it. Is there anyway to get the test-classes before classes in the classpath order? Setting childDelegation to true doesn't. I'm not 100% certain you're using the software you think you're using; here's some debugging/analysis tips. 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/[EMAIL PROTECTED]/msg00432.html As noted in 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 for me with Surefire 2.4.1 (and 2.4.2-SNAPSHOT) and Maven 2.0.8, and failing with Maven 2.0.7. Finally, note that your real classpath is being output in your target/surefire-reports/*.xml files as the surefire.test.classpath property; that may be useful for debugging purposes. -Dan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Surefire 2.4.1 classpath order
Ken Liu wrote: Do you know if that bug was introduced in 2.0.7 (or some other earlier release)? I talked about two JIRA issues; their interactions are complex. SUREFIRE-61 is listed as affecting 2.0 (2.2 plugin); that means it has probably been around for a long time. MNG-3118 is an Improvement and not a Bug; it was filed in July of 2007, but for all I know Maven has been behaving the old bad way since 2.0.0. What's complex about this problem is that the two issues obfuscate each other. For many users, Maven was trying to use the wrong classpath, but Surefire was accidentally reversing it, resulting in the right classpath for some users. Since both bugs have been fixed in the latest versions of the software, people who get only one fix and not the other will suffer. :-( My team is using 2.0.4 and we encountered a problem with the classpath ordering recently that caused builds to that were previously working to suddenly start failing. If your project doesn't explicitly declare a version of Surefire, it will be automatically upgraded to the latest version (currently 2.4.1). The developers who designed that feature are very sorry about it. ;-) Based on what I think I know about this problem, you're probably being auto-upgraded to 2.4.1; Surefire 2.4.1 + Maven 2.0.4 = bad classpath ordering. -Dan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Surefire 2.4.1 classpath order
Hi, I have another related query regarding surefire, all of a sudden from today we started getting this error while executing JUnit tasks, the compilation of source file happens fine and the when compiling the test source files, the maven gives build failure telling that it was not able to load main class from C:\WINDOWS\TEMP\surefirebooter59557.jar What is going wrong here? Could someone please help on this? Regards, Amit On Fri, Feb 15, 2008 at 4:16 PM, Ben Lidgey [EMAIL PROTECTED] wrote: Hi We are running tests using Surefire 2.4.1 and Maven 2.0.8. The Junit test classes are expecting to load a properties file from src/test/resources with the same name as a properties file in src/main/resources to load test data etc. However the src/main/resources properties file is being loaded. Looking at the debug output shows: [DEBUG] Test Classpath : [DEBUG] C:\Documents and Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar [more jars] [DEBUG] c:\Development\Projects\MyProject\target\classes [DEBUG] c:\Development\Projects\MyProject\target\test-classes Which would explain it. Is there anyway to get the test-classes before classes in the classpath order? Setting childDelegation to true doesn't. Ben Lidgey Senior Software Engineer e: [EMAIL PROTECTED] Inuk Networks Limited Enterprise House Navigation Park Abercynon CF45 4SN t: +44 (0)844 546 0100 f: +44 (0)844 546 0200 w: www.inuknetworks.com This e-mail is confidential and intended solely for the use of the individual(s) to whom it is addressed. Any views or opinions expressed are those of the author. If you are not the intended recipient, please be advised that any use, dissemination, printing or copying of this email is strictly prohibited. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
surefire-booter manifest issue (was Re: Surefire 2.4.1 classpath order)
On Today at 4:50pm, ak=amit kumar [EMAIL PROTECTED] wrote: ak Hi, ak I have another related query regarding surefire, all of a sudden from ak today we started getting this error while executing JUnit tasks, the ak compilation of source file happens fine and the when compiling the ak test source files, the maven gives build failure telling that it was ak not able ak Its not exactly related but you might be running into: http://jira.codehaus.org/browse/SUREFIRE-451 Its been fixed and should be in 2.4.2 (I have no idea when it will be released. I am not a committer). You can read the last comment on the jira which points you to a previous thread on the mailing list: http://jira.codehaus.org/browse/SUREFIRE-451#action_122858 ak ak to load main class from ak C:\WINDOWS\TEMP\surefirebooter59557.jar ak ak What is going wrong here? ak Could someone please help on this? ak ak Regards, ak Amit ak Cheers, -- Haroon Rafique [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Surefire 2.4.1 classpath order
Ben Lidgey wrote: We are running tests using Surefire 2.4.1 and Maven 2.0.8. [...] Looking at the debug output shows: [DEBUG] Test Classpath : [DEBUG] C:\Documents and Settings\benl\.m2\repository\junit\junit\4.2\junit-4.2.jar [more jars] [DEBUG] c:\Development\Projects\MyProject\target\classes [DEBUG] c:\Development\Projects\MyProject\target\test-classes Which would explain it. Is there anyway to get the test-classes before classes in the classpath order? Setting childDelegation to true doesn't. I'm not 100% certain you're using the software you think you're using; here's some debugging/analysis tips. 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/[EMAIL PROTECTED]/msg00432.html As noted in 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 for me with Surefire 2.4.1 (and 2.4.2-SNAPSHOT) and Maven 2.0.8, and failing with Maven 2.0.7. Finally, note that your real classpath is being output in your target/surefire-reports/*.xml files as the surefire.test.classpath property; that may be useful for debugging purposes. -Dan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]