2014-10-16 38 views
2

我繼承了一個Grails應用程序,在全新結帳時,我無法運行。當然,最初從事這個項目的人早已不在了。我有其他的Grails項目運行正常(開箱即可),所以我知道這不是我的配置。在2.1.1項目中找不到GrailsCompiler

設置信息:

> 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 

回聲$ 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[] 

沒有我似乎做不會越過這個或改變它。任何人有任何想法如何解決這個問題?

回答

2

運行grails升級 - 仍然不知道爲什麼這可以工作,但我不得不偶爾做一個新的結帳。

2

檢查依賴性:

grails dependency-report 

檢查輸出對Groovy的多個版本或Spring在構建配置。 http://grails.org/doc/latest/ref/Command%20Line/dependency-report.html

  • 使用排除或特定依賴於BuildConfig.groovy使用某些版本。
  • 請務必檢查不同的配置,因爲一些依賴關係可能只是在測試配置中,而另一個版本則在編譯或構建中。這可能有時是依賴關係的問題。

引用: http://grails.1312388.n4.nabble.com/Upgrading-a-project-from-1-3-6-to-1-4-0-M1-td3603895.html

另一個檢查:

確保你沒有〜/趙軍陽張志利/ lib目錄下。我已經看到,導致奇怪的問題。

如果它存在其重命名爲:

mv ~/.ant/lib{,.old} 

嘗試直接升級到2.3.11的Grails以來的2.1.x或2.2.x的Grails的分支機構不能維持了。查看grails.org網站的發佈說明(https://grails.org/Releases)和grails參考手冊獲取升級說明。

你應該在這些指令看看:從2.1.x的

升級到2.2.x的:從2.2.x的

http://grails.org/doc/2.2.x/guide/upgradingFromPreviousVersionsOfGrails.html

升級到2.3。X: https://grails.org/Releases

一些額外的升級提示:

  • 刪除所有插件依賴從application.properties文件和

    http://grails.org/doc/2.3.x/guide/upgradingFromPreviousVersionsOfGrails.html

    閱讀所有發行說明的版本後,要升級將它們移動到BuildConfig.groovy

  • 比較空應用程序的grails-app/conf/*和web-app/WEB-INF/*文件(o fa新版本)到你的應用程序與像Meld,WinMerge等diff工具
  • 如果您有一個模板目錄,將其與安裝了模板的空應用程序(的新版本)進行比較(grails install-templates )。
+0

拉里修正了這個 - 我給了比蒂的答案但這是好事。有趣的是,我沒有做升級和(顯然)該應用程序運行2.1.1。在生產中。不知道爲什麼它對我來說很奇怪。但這都是好東西。 – MikeHoss 2014-10-22 13:05:20

1

我有一個類似的問題,@貝蒂的答案沒有工作,因爲這也會給我一個錯誤。以下一些可能的解決方案,我發現here,我通過刪除target夾在我的應用程序的文件夾

rm -rf target/* 

,然後重新運行grails compile

希望這有助於