我继承了一个Grails应用程序,在新结账时,我无法运行。当然,最初参与这个项目的人早已不复存在。我有其他正确运行的Grails项目(开箱即用)所以我知道这不是我的配置。
设置信息:
> cat application.properties
#Grails Metadata file
#Tue Jul 09 16:31:14 IST 2013
app.grails.version=2.1.1
app.name=myapp
app.version=0.1
> grails -version
Grails version: 2.1.1
echo $ GROOVY_HOME /cygdrive/c/Users/myuser/.gvm/groovy/current
> echo $GRAILS_HOME
/cygdrive/c/Users/myuser/.gvm/grails/2.1.1
现在是栈跟踪:
grails run-app --stacktrace
| Configuring classpath.
Environment set to development
| Configuring classpath.....
| Error Error executing script RunApp: taskdef class org.codehaus.groovy.grails.compiler.GrailsCompiler cannot be found
using the classloader AntClassLoader[] (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: org.codehaus.groovy.grails.compiler.GrailsCompiler
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1361)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1311)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1064)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:594)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:239)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:99)
at _GrailsCompile_groovy.run(_GrailsCompile_groovy:32)
at _GrailsCompile_groovy$run.call(Unknown Source)
at _GrailsPackage_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsPackage_groovy.run(_GrailsPackage_groovy:38)
at _GrailsPackage_groovy$run.call(Unknown Source)
at _GrailsSettings_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsPlugins_groovy.run(_GrailsPlugins_groovy:33)
at _GrailsPlugins_groovy$run.call(Unknown Source)
at _GrailsRun_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at _GrailsRun_groovy.run(_GrailsRun_groovy:31)
at _GrailsRun_groovy$run.call(Unknown Source)
at org.codehaus.gant.IncludeTargets.leftShift(IncludeTargets.groovy:59)
at org.codehaus.gant.IncludeTargets$leftShift.call(Unknown Source)
at RunApp.run(RunApp.groovy:25)
at RunApp$run.call(Unknown Source)
at gant.Gant.prepareTargets(Gant.groovy:607)
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231)
| Error Error executing script RunApp: taskdef class org.codehaus.groovy.grails.compiler.GrailsCompiler cannot be found
using the classloader AntClassLoader[]
我似乎没有做过任何事情或者改变它。任何人有任何想法如何解决这个问题?
答案 0 :(得分:2)
运行grails升级 - 仍然不确定为什么这会有效但我必须偶尔通过新的结账来实现。
答案 1 :(得分:2)
检查依赖项:
grails dependency-report
在构建配置中检查多个版本的Groovy或Spring的输出。 http://grails.org/doc/latest/ref/Command%20Line/dependency-report.html
的引用: http://grails.1312388.n4.nabble.com/Upgrading-a-project-from-1-3-6-to-1-4-0-M1-td3603895.html
另一项检查:
确保没有〜/ .ant / lib目录。我见过那会引起奇怪的问题。
如果存在则重命名:
mv ~/.ant/lib{,.old}
尝试直接升级到Grails 2.3.11,因为2.1.x或2.2.x Grails分支不再维护。请查看grails.org网站(https://grails.org/Releases)的发行说明和grails参考手册以获取升级说明。
您应该看看这些说明:
从2.1.x升级到2.2.x:
http://grails.org/doc/2.2.x/guide/upgradingFromPreviousVersionsOfGrails.html
从2.2.x升级到2.3.x:
http://grails.org/doc/2.3.x/guide/upgradingFromPreviousVersionsOfGrails.html
在升级版本之后阅读所有发行说明: https://grails.org/Releases
一些额外的升级提示:
答案 2 :(得分:2)
我遇到了类似的问题,@ Beatty的回答没有用,因为这也会给我一个错误。根据我找到here的一些可能的解决方案,我通过删除应用程序文件夹中的target
文件夹来修复此问题
rm -rf target/*
然后再次运行grails compile
希望这有帮助