Symptom: after installing or upgrading to Grails 2.0.2 though IntelliJ (Tools/Grails/Change SDK Version), you get a Classloader error like this :
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/tools/RootLoader Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.RootLoader 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) IDEA Hook: Grails not found!
The reason is simple: IDEA expects to find groovy-all jar file immediately under $GRAILS_HOME/org.codehaus.groovy/groovy-all/jars. But 2.0.2 version puts it under version id, as shown below (I installed Grails directly in my home directory):
~/grails-2.0.1/lib/org.codehaus.groovy/groovy-all/jars/groovy-all-1.8.6.jar
vs
~/grails-2.0.2/lib/org.codehaus.groovy/groovy-all/1.8.6/jar/groovy-all-1.8.6.jar
The fix is simple, just create a symbolic link to help IDEA find the correct jar:
$ cd grails-2.0.2/lib/org.codehaus.groovy/groovy-all $ ln -s 1.8.6/jar ./jars
This allows both IDEA and grails to find groovy-all-1.8.6.jar, thus keeping interactive grails working.
OK, symlinks only exist on Linux and MacOS. I guess a simple copy of groovy-all-1.8.6.jar on both places should to the job on Windows.
Aucun commentaire:
Enregistrer un commentaire