1

I have just upgraded to...

  • Grails 1.4.0.M1
  • Groovy 1.8.0
  • STS Version: 2.7.0.M2 Build Id: 201106101000 - 64bit Cocoa version for Mac
  • I have OS X 10.5.8. with JVM 1.5.0

When I run a grails command eg 'create-app' or 'upgrade' on an existing project I get the following NoClassDefFoundError for the GantBuilder. (see below for full trace)

A proposed solution for a similar problem from this forum is that gant_groovy1.8-1.9.5.jar is missing. I've added this to the project directly and also to a groovy/lib folder (and gone to STS -> preferences -> Groovy -> compiler -> Update All Groovy Classpath Containers) but I still get the error. (When I added gant_groovy1.8-1.9.5.jar to groovy/lib it was to a separate groovy download, I'm not sure which groovy/lib folder STS uses for the internal grails shell commands or how to view the STS groovy class path)

found org.springframework#spring-test;3.1.0.M1 in default
:: resolution report :: resolve 2068ms :: artifacts dl 119ms
---------------------------------------------------------------------
|                  |            modules            ||   artifacts   |
|       conf       | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
|       test       |   74  |   0   |   0   |   0   ||   74  |   0   |
---------------------------------------------------------------------
Script threw exception
java.lang.NoClassDefFoundError: org.codehaus.gant.GantBuilder
    at org.codehaus.gant.GantBinding.class$(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.$get$$class$org$codehaus$gant$GantBuilder(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.<init>(GantBinding.groovy:41)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.callPluginOrGrailsScript(GrailsScriptRunner.java:448)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.runInteractive(GrailsScriptRunner.java:377)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.executeCommand(GrailsScriptRunner.java:308)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.java:130)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:592)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:234)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:262)

Does anyone have any ideas?

Chris
  • 3,552
  • 2
  • 26
  • 36
  • excuseme, but does my answer help? I went on vacation for several days, and when I come back it seems you still have troubles, but I forget to follow. You doesn't need to mark my answer as accepted because it's the unique answer. – Hoàng Long Jun 21 '11 at 02:07
  • @Hoang, thanks your answer did help. I overcame a couple of additional problems and wrote up solutions by editing your answer. Please could accept the edits so they're available to everyone. – Chris Jun 23 '11 at 14:06
  • sorry, but I don't have the priviledge to review or accept your edits. But you can edit your question & put the complete answer – Hoàng Long Jun 23 '11 at 15:14

1 Answers1

2

If what I understand is right, Grails don't use the jar in your groovy/lib folder, but the jar in the Grails Installation folder. You may want to try this:

According to the post here, you should go to the Installed Grails Folder (%GRAILS_HOME%). In that folder, find the lib folder, and specify the right version of gant_groovy.jar that you have. Then edit the %GRAILS_HOME%/bin/startGrails.bat as text and add this line:

( set STARTER_CLASSPATH=%GRAILS_HOME%\lib\org.codehaus.groovy\groovy-all\jars\groovy-all-1.8.0.jar;%GRAILS_HOME%\dist\grails-bootstrap-1.4.0.M1.jar;%GRAILS_HOME%\lib\org.codehaus.gant\gant_groovy1.8\jars\gant_groovy1.8-1.9.5.jar 
)

Note that the path on the above line is not very accurate(it seems different for each distribution). You should find the required jar in the %GRAILS_HOME% folder and change the path accordingly.

Hoàng Long
  • 10,746
  • 20
  • 75
  • 124
  • Note 1: If you are running in STS then it may be that STS does not pick up the changes you made to your startGrails script or .bat file. In this case go to the project home directory, add the startGrails script to your path and then run the startGrails from the command line. Please also see [here](http://stackoverflow.com/questions/6418027/grails-where-is-the-startgrails-script-in-eclipse-sts-on-the-mac) – Chris Jun 23 '11 at 18:21
  • Note 2: If the original problem is fixed and you then get an error similar to... "Error executing script CreateApp: Bad version number in .class file, java.lang.UnsupportedClassVersionError: Bad version number in .class file" then check your Java version. I was originally on Java 1.5. Linking the startGrails to Java 1.6 fixed this problem. [Further information about the 'java.lang.UnsupportedClassVersionError: Bad version number in .class file' is here](http://stackoverflow.com/questions/2466828/java-lang-unsupportedclassversionerror-bad-version-number-in-class-file) – Chris Jun 23 '11 at 18:23