2014-11-13 93 views
0

我在Windows上使用Grails 2.3.5,並使用命令行中的grails create-app命令創建了項目。當我從命令行運行grails run-app --verbose時,我得到下面的異常。當我運行grails run-app命令時,我得到的緩存停用失敗,無法創建緩存

Caching deactivated: failed to create cache directory: C:/grails/2.3.5/ 
java.lang.NoClassDefFoundError: org/apache/catalina/startup/Tomcat 
    at... 
Caused by: java.lang.ClassNotFoundException: org.apache.cataliina.startup.Tomcat 

下面是我的我的BuildConfig.groovy文件

... 
     dependencies { 
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g. 
     //compile 'xlan:serializer:jar:2.7.1' 
     // runtime 'mysql:mysql-connector-java:5.1.27' 
     // runtime 'org.postgresql:postgresql:9.3-1100-jdbc41' 
     //These were added for mongodb 
     compile 'org.grails:grails-datastore-gorm:3.1.0.RELEASE' 
     compile 'org.grails:grails-datastore-core:3.1.0.RELEASE' 
     test 'org.grails:grails-datastore-simple:3.1.0.RELEASE' 
     compile "net.sf.ehcache:ehcache-core:2.4.6" 
     compile 'org.grails:grails-async:jar:2.3.8' 
     compile 'org.springframework:spring-tx:3.2.8.RELEASE' 
    } 

    plugins { 
     // plugins for the build system only 
     //build ":serializer:2.7.1" 
     build ':tomcat:7.0.50' 
     // plugins for the compile step 
     compile ":scaffolding:2.0.1" 

     //compile ':cache:1.1.1' 
     compile ':mongodb:3.0.1' 
     compile ":jquery-ui:1.10.3" 

     compile ":spring-security-core:2.0-RC4" 
     // plugins needed at runtime but not for compilation 
     // runtime ":hibernate:3.6.10.7" // or ":hibernate4:4.1.11.6" 
     runtime ":database-migration:1.3.8" 
     runtime ":jquery:1.10.2.2" 
     runtime ":resources:1.2.1" 
     // Uncomment these (or add new ones) to enable additional resources capabilities 
     //runtime ":zipped-resources:1.0.1" 
     //runtime ":cached-resources:1.1" 
     //runtime ":yui-minify-resources:0.1.5" 
    }... 

的一部分,我運行這個Grails的指向本地存儲庫的離線模式。 這隻成功編譯後,我加入我的Groovy/Grails的工具包文件夾下面列出我的lib文件夾的罐子,這樣他們將在類路徑 (這個固定在卡特琳娜的TomcatKillSwitch錯誤)

  1. catalina.jar
  2. 卡塔利娜-的ant.jar
  3. 卡塔利娜-ha.jar
  4. 卡塔利娜-tribes.jar
  5. Tomcat的api.jar文件
  6. Tomcat的coyote.jar
  7. 的tomcat-util.jar

爲什麼不能發現的Grails和Tomcat爲什麼不能創建一個緩存?

+0

我已經嘗試過乾淨,乾淨的所有以及刪除目標文件夾 –

回答

0

刪除這些jar文件;你可能已經「解決」了這個問題,但你真的只是隱藏了一個症狀,問題依然存在,並且會重新出現,可能是下次添加插件時。繼續並刪除lib目錄 - 它可能會繼續誘惑你的存在。

在我看來,核心問題很簡單明瞭; Grails無法創建C:/grails/2.3.5/。副作用沒有明確說明,其中一個是Grails無法正確解壓Tomcat插件(也可能是其他的),並用它的源代碼和jar依賴關係來擴充classpath。

針對此問題的適當修復將是升級到合理的操作系統。我建議Linux,其他人覺得成爲一大羣怪異的'個人'的一部分的舒適,並會建議OSX,但真的什麼,但Windows會做。

我要在這裏出去走走,並聲稱如果您要完成手動創建c:\grails的任務,您可以結束這個黑暗時期的緩存貧困。默認情況下,無法在最新版本的Windows中的C:驅動器的根目錄下創建文件或目錄;當然這是可能的,並且在這個旅程中你會被問到太多的「你確定」類型的問題,但它可以完成。

然後,您將在重啓後擁有高速緩存,因爲Grails能夠創建2.3.5目錄,解壓插件並以編程方式引用先前下載/緩存的Tomcat JAR,而不必將它們放在lib中目錄。

+0

謝謝,這是問題所在。我的管理員不允許我寫入到c:驅動器。所以我改變了GRAILS_AGENT_CACHE_DIR環境變量指向一個我可以編寫的地方,並且沒有更多地創建.grails/2.3.5目錄。 –

+0

針對jar問題。我刪除了像你推薦的所有罐子。結果錯誤是一個ClassDefNotFoundException org.apache.catilina.Tomcat。我通過清除我的user/.m2/repository文件夾並重新編譯來解決這個問題,這樣就可以刷新缺失的依賴關係 - 實際上缺少了tomcat-embed-core.jar。這解決了運行應用程序和編譯問題。謝謝你的回答! –

相關問題