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.

Samstag, Juni 27, 2009

mixing Java and Groovy in Eclipse

As a server back end for Greasemonkey calls I use com.sun.net.httpserver.HttpServer. The work is done inside an implementation of the com.sun.net.httpserver.HttpHandler interface. To write the HttpHandler in Java started to take more time as I was willing to spend. So I thought it is a good idea to try out Groovy.

Installing Groovy and the corresponding Eclipse plugin was no problem. Running the first test script was straight forward also. But compiling a Java and a Groovy class inside the same project didn't work.

Therefore I did a test by hand.

  • set JAVA_HOME and GROOVY_HOME

  • compile the Groovy class inside projects src directory:

    1. groovyc PlayHttpHandler.groovy

    2. javac AjaxHttpHandler.java

    3. javac AjaxHttpServer.java


  • start the server: java -cp /Volumes/Macintosh\ HD/Applications/groovy-1.6.3/embeddable/groovy-all-1.6.3.jar AjaxHttpServer


This worked. So try again in Eclipse.

First step was to clean the project. But it still doesn't work. All classes are build twice. In bin the Groovy class has an unresolved compile problem. To me it looks like the class was build with javac. In bin-groovy the Groovy class is OK. Unfortunately the Groovy class used during run time is the one from bin. Not sure how to fix this.

Donnerstag, Juni 25, 2009

Javascript speed of Firefox 3.5

Today I installed Firefox 3.5 RC. The first thing I did was to test the speed of the new Javascript engine. For this I used sunspider. On my machine Safari is still twice as fast as Firefox.

But as long as Safari has no security features like NoScript and CS Lite I will not use it.