grails - 当我运行grails run-app命令时,我停用了缓存,无法创建缓存

标签 grails embedded-tomcat-7 run-app

我在Windows上使用Grails 2.3.5,并已从命令行使用grails create-app命令创建了项目。当我从命令行运行grails run-app --verbose时,出现以下异常。

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脱机模式,指向本地存储库。
这仅在之后成功编译,我将下面列出的jar添加到我的Groovy / Grails工具套件文件夹中的lib文件夹中,以便它们位于类路径中
(这修复了catalina中的TomcatKillSwitch错误)
  • catalina.jar
  • catalina-ant.jar
  • catalina-ha.jar
  • catalina-tribes.jar
  • tomcat-api.jar
  • tomcat-coyote.jar
  • tomcat-util.jar

  • 为什么Grails无法找到Tomcat,为什么它不能创建缓存?

    最佳答案

    删除这些jar文件;您可能已经“解决”了这个问题,但是您实际上只是隐藏了一个症状,问题仍然存在,并且很可能在您下次添加插件时再次出现。继续删除lib目录-它可能只会继续诱惑您它的存在。

    在我看来,核心问题很简单而且很明确; Grails无法创建C:/grails/2.3.5/。副作用没有明确说明,其中之一是Grails无法正确解压缩Tomcat插件(可能还包括其他插件),并无法通过其源和jar依赖项扩展类路径。

    解决此问题的适当方法是升级到明智的OS。我建议使用Linux,其他人则可以加入很多志同道合的“个人”,并会建议使用OSX,但Windows除外。

    我将在这里走出去,声称如果您要承担手动创建c:\grails的任务,则可以结束这个黑暗的缓存贫困时期。默认情况下,您不能在Windows的最新版本的C:驱动器的根目录中创建文件或目录;当然是有可能的,并且在此过程中会被问到太多“您确定”类型的问题,但这是可以做到的。

    重新启动后,您将拥有丰富的缓存,因为Grails能够创建2.3.5目录,解压缩插件并以编程方式引用以前下载/缓存的Tomcat jar,而不必将它们放在lib目录中。

    关于grails - 当我运行grails run-app命令时,我停用了缓存,无法创建缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26918671/

    相关文章:

    javascript - 我在保存日期和时间时遇到问题?

    grails - 使用 Grails 2.x 和 Spring Security 插件实现字段级安全

    json - 使用默认Grails JSON渲染器时的Snake case json

    grails - Intellij IDEA x Grails

    java - tomcat7-maven-plugin 无法从 react 器中找到依赖项

    java - 限制嵌入式 Tomcat 中的密码

    Spring 启动 : Dynamic ServletPath and ContextPath for Embedded Tomcat

    grails - Grails应用无法运行

    android - 错误 : resizing partition e2fsck failed with exit code 8