Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369349

Summary: space in filename fix broke integration tests
Product: [RT] Jetty Reporter: Greg Wilkins <gregw>
Component: buildAssignee: Thomas Becker <tbecker>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jesse.mcconnell, jetty-inbox, tbecker
Version: 8.1.0.RC4   
Target Milestone: 7.5.x   
Hardware: All   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
proposed patch - not 100% working yet
none
proposed patch
none
fix for --dry-run none

Description Greg Wilkins CLA 2012-01-22 20:43:30 EST
The change 3df95d45c27c924c1f0e76c4c16a3f796ddf2470 to fix tests with spaces in them, broke the tests/test-integration monitor tests.  These started failing with class not found exceptions.

It appears that the quotes are making the JVM think that arguments are actually the main class.

I tried making a change so that instead of "-Dname=value" the quoting was done as -Dname="value".  This improved it a little, but it still failed with:

Running org.eclipse.jetty.test.monitor.JavaMonitorIntegrationTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.003 sec
Running org.eclipse.jetty.test.monitor.XmlConfigTest
Copying Jetty Distribution: /home/gregw/src/jetty-7/tests/test-integration/target/test-dist/jetty-distribution-7.6.0-SNAPSHOT
            To Testing Dir: /home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome
Executing: /usr/local/jvm/jdk1.6.0_29/jre/bin/java -Djetty.home="/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome" -cp "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-xml-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/servlet-api-2.5.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-http-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-continuation-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-server-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-security-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-servlet-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-webapp-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-deploy-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-servlets-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-jmx-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/com.sun.el_1.0.0.v201004190952.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/ecj-3.6.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/javax.el_2.1.0.v201004190952.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/javax.servlet.jsp_2.1.0.v201004190952.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/javax.servlet.jsp.jstl_1.2.0.v201004190952.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/org.apache.jasper.glassfish_2.1.0.v201110031002.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jsp/org.apache.taglibs.standard.glassfish_1.2.0.v201004190952.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/resources:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-websocket-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-util-7.6.0-SNAPSHOT.jar:/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/lib/jetty-io-7.6.0-SNAPSHOT.jar" org.eclipse.jetty.xml.XmlConfiguration "/tmp/start8255937009651302414.properties" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty-jmx.xml" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty.xml" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty-deploy.xml" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty-webapps.xml" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty-contexts.xml" "/home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome/etc/jetty-testrealm.xml"
Working Dir: /home/gregw/src/jetty-7/tests/test-integration/target/tests/oejtm.XmlConfigTest/jettyHome
[STDERR] Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/xml/XmlConfiguration
[STDERR] Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.xml.XmlConfiguration
[STDERR] 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[STDERR] 	at java.security.AccessController.doPrivileged(Native Method)
[STDERR] 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[STDERR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[STDERR] 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[STDERR] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[STDERR] Could not find the main class: org.eclipse.jetty.xml.XmlConfiguration.  Program will exit.
Stopping JettyDistro ...
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 60.985 sec <<< FAILURE!

So this looks like the command line is being correctly parsed, but that the classpath is somehow not being interpreted correctly.


So Rolling back the change for now.
Comment 1 Greg Wilkins CLA 2012-01-22 21:15:03 EST
Instead of rolling back, I've replaced the quotes with a method excapeSpaces that will \ escape strings with spaces in them.  This means there is no change to the output if there are no spaces.  The it now builds for me.

But I leave this open as the full build needs to be tested with spaces in filenames.
Comment 2 Thomas Becker CLA 2012-01-30 15:41:51 EST
I've written a Unit Test which tests spaces in pathnames for:

- jetty.home
- classpath
- xml config files

And that jvmArgs are correctly parsed and separated with spaces. I also rewrote the patch. Practically I did intuitively the same thing as greg by writing a escapeSpaces(String) method.

It works fine, but classpath needs some more love. Will take care for it tomorrow.
Comment 3 Thomas Becker CLA 2012-01-30 15:49:42 EST
Created attachment 210283 [details]
proposed patch - not 100% working yet

I've added a Unit Test for building the commandline and fixed the code accordingly. However this patch is not finished, I'm just providing it so Joakim can work on it.

The code is not yet beautified and the classpath issue needs to be fixed.
Comment 4 Joakim Erdfelt CLA 2012-01-31 13:19:55 EST
Closing, as we now have working jmx/monitoring/integration tests again.
Comment 5 Thomas Becker CLA 2012-01-31 16:40:50 EST
Created attachment 210339 [details]
proposed patch

This was a nasty one. I thought 3 or 4 times that I've found the solution, but testing revealed that either the one thing or the other still has not been working. And the solution to get everything working was not the one you'd expect in the beginning. 

Actually for the classpath you shouldn't escape any space nor add any quotes. Then it works for the build, jetty single jvm start and --exec start.

Patch attached.
Comment 6 Joakim Erdfelt CLA 2012-01-31 16:43:05 EST
Reopening for Thomas to continue working failing use case.
Comment 7 Greg Wilkins CLA 2012-02-01 03:07:49 EST
applied and tested
Comment 8 Greg Wilkins CLA 2012-02-01 03:11:39 EST
The output from --dry-run is not quoted.
Comment 9 Thomas Becker CLA 2012-02-01 04:24:07 EST
Created attachment 210362 [details]
fix for --dry-run
Comment 10 Thomas Becker CLA 2012-08-21 10:08:01 EDT
Patch finally applied.
Comment 11 Jesse McConnell CLA 2012-08-21 10:10:37 EDT
closing