Sonntag, Juni 28, 2009

groovy tools very picky at GROOVY_HOME

Today my groovy script wouldn't start. It couldn't find org/apache/commons/cli/CommandLineParser. As I didn't use this class I tried groovy -version. This also produced:

java.lang.NoClassDefFoundError: org/apache/commons/cli/CommandLineParser
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod(Class.java:1603)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:99)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.CommandLineParser
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:402)
... 6 more

Next I checked if I had set GROOVY_HOME and JAVA_HOME. OK.

Asked the web and found a bug report with the same error message. The conclusion is that startGroovy fails to accesses some resources, if a constructed path from GROOVY_HOME, contains //.

As I had created my GROOVY_HOME with TAB completion, the path had a / at the end. Removing this one fixed the problem.

Keine Kommentare: