8

我使用 Grails 2.3 和 Grails 数据库迁移插件 (1.3.6)。

当我执行 grails dbm-update 时,出现以下错误。我该如何解决这个错误?

 Error Error loading plugin manager: TomcatGrailsPlugin (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.ClassNotFoundException: TomcatGrailsPlugin
    at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:40)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at _GrailsBootstrap_groovy$_run_closure6.doCall(_GrailsBootstrap_groovy:64)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
    at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
    at _DatabaseMigrationCommon_groovy$_run_closure1.doCall(_DatabaseMigrationCommon_groovy:25)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
    at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
    at DbmUpdate$_run_closure1.doCall(DbmUpdate:23)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
    at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
    at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:591)
    at gant.Gant.executeTargets(Gant.groovy:590)
| Error Error loading plugin manager: TomcatGrailsPlugin
4

6 回答 6

11

这是一个超级烦人的错误。我的应用程序依赖于使用 run-script 运行脚本,我得到了相同的行为。这是我作为解决方法所做的:

plugins {
    ...
    // grails 2.3.2 and tomcat 7.0.42 cause scripts to not work :( Pass -DnoTomcat=true in the script args to fix this
    if (System.getProperty("noTomcat") == null) {
        build ":tomcat:7.0.42"
    }
}

然后在运行脚本时:

 grails -DnoTomcat=true run-script scripts/MyScript.groovy

确实很烦人,但至少您可以在等待修复时使用所有其他最新功能。

于 2013-11-18T02:10:53.583 回答
5

尝试将 buildConfig.groovy 中的 tomcat 构建类型更改为编译而不是构建:

compile ':tomcat:7.0.42'

于 2013-10-20T21:22:05.207 回答
2

因此,如果您发现这个是因为您的脚本被 2.3.x 破坏了,那么这就是我发现的关于该问题的一般情况。我仍然不能使用 run-script 因为它总是因可怕的 TomcatPlugin 丢失问题而失败(我怀疑这意味着 run-script 总是试图引导 grails 而不管)。但是,我可以让脚本编译并作为任务运行。我的脚本总是会失败,因为我使用以下方法引导 grails:

includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsBootstrap")
includeTargets << grailsScript("_GrailsClasspath")

target(main: "Generate a secret key to be used with HMAC and AES algorithms") {
   depends(bootstrap)  // this is problem
}

所有这些都来自说要这样做的文档。但是,depends(bootstrap) 在 2.3.x 中被严重破坏,这是整个 fork 功能崩溃的一部分(是的,它没有经过深思熟虑)。

因为我很幸运,而且我的脚本并不需要完全引导 grails,所以我可以执行以下操作,并且效果也很好:

includeTargets << grailsScript("_GrailsInit")
includeTargets << grailsScript("_GrailsBootstrap")
includeTargets << grailsScript("_GrailsClasspath")

target(main: "Generate a secret key to be used with HMAC and AES algorithms") {
   depends(parseArguments)  // this is not problem
}

中提琴又开始工作了。工作得很好。这是有效与无效的:

$ grails GenerateSecretKey              // yay works
$ grails run-script GenerateSecretKey   // doesn't work

以下是有关此问题的一些 Jira 问题,因此您会知道所有这些都是错误的;-)

于 2014-03-18T16:09:21.700 回答
1

我在 Grails 2.3.4 上,但这是我解决此问题的方法:

  1. 升级到数据库迁移 1.3.8
  2. 清除了我的 scriptCache 文件夹
  3. 执行的刷新依赖

重试数据库迁移脚本,问题解决。

于 2013-12-09T03:23:42.170 回答
0

只是稍微澄清一下,上面提到了chubbsondubs,但我在第一次阅读时错过了......

通常,对此的简单答案是:

grails run-script scripts/DoSomething

这样做:

grails do-something
于 2014-10-28T15:47:50.170 回答
0

升级到 2.3.2 时我遇到了同样的问题

我用标志 -DnoTomcat 尝试了上述方法

它仍然无法正常工作。然后我意识到有一些就地插件也引用了 tomcat。这在某种程度上似乎是遗留问题,因为使用 grails 2.3.2 新创建的插件没有对 tomcat 的引用。所以我只是从插件中删除了所有引用,并将标志开关保留在我的主应用程序中。

于 2013-11-20T11:57:53.537 回答