Surefire, jenkins and NoClassDefFoundException – why not to use white spaces in Jenkins job names

Well, jenkins errors can be mysterious at times..

message : Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) 
on project XXX: ExecutionException; nested exception is 
java.util.concurrent.ExecutionException: java.lang.RuntimeException: 
The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?

No, we don’t call System.exit() from our tests :-) Why would surefire be so rude to cause VMs not say properly goodbye?

Maven -e option coming to the rescue. Analyzing entire error and the command line being invoked by surefire here we can see that jenkins attempts to fork in a directory with spaces, which will fail later on in linux when java starts. I haven’t found any immediate solution other than renaming the job to something safe.

Forking command line: /bin/sh -c cd "/etc/web/jenkins/workspace/commit full build/xx/yy/zzz" 
&& /etc/web/jenkins/tools/hudson.model.JDK/jdk1.6.0_45-jaxwsEndorsed/jre/bin/java 
-Xms512m -Xmx1024m -XX:MaxPermSize=256m -Djava.security.manager 
-Djava.security.policy=/sbclocal/web/jenkins-home/workspace/commit full build/xxx/yyy/zzzz/../../src/test/resources/java.policy 
-jar '/etc/web/jenkins-home/workspace/commit full build/tesscoll/pu/customer/target/surefire/surefirebooter2206155077895318006.jar' 
Exception in thread "main" java.lang.NoClassDefFoundError: full 
Caused by: java.lang.ClassNotFoundException: 
full at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 
Could not find the main class: full. Program will exit.