简体   繁体   中英

“Error loading plugin manager: TomcatGrailsPlugin” on Grails 2.3 Database Migration

I use Grails 2.3 and the Grails database migration plugin (1.3.6).

When I do grails dbm-update I get the following error. How can I solve this error?

 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

This is a super annoying bug. My application depends on running scripts with run-script and I get the same behavior. Here's what I did as a workaround:

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"
    }
}

Then when running your script:

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

Annoying for sure, but at least you can use all the other latest features while awaiting a fix.

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

compile ':tomcat:7.0.42'

So if you are finding this because your scripts are broken by 2.3.x here is what I discovered about the problem in general. I still can't use run-script because it always fails with the dreaded TomcatPlugin missing problem (I suspect this means run-script is always trying to bootstrap grails irregardless). However, I can get the scripts to compile and run as tasks. My scripts would always fail because I had bootstrapped grails using the following method:

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
}

All of that is from the docs that say to do that. However, depends(bootstrap) is broken badly in 2.3.x which is apart of the whole fork feature debacle (yes it was not well thought out).

Since I got so lucky and my scripts don't really have to fully bootstrap grails I could do the following and it worked just as well:

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
}

And viola it started working again. Well working-ish. Here is what works vs doesn't work:

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

Here are some Jira issues about this problem(s) so you'll know when all of this is wrong ;-)

I'm on Grails 2.3.4, but here's how I fixed this problem:

  1. Upgraded to database migration 1.3.8
  2. Cleared my scriptCache folder
  3. Executed refresh-dependencies

Retried the database migration script, and the problem was resolved.

I had the same issue when upgrading to 2.3.2

I tried the above with the flag -DnoTomcat

It was still not working. Then I realised having some inplace plugins referencing tomcat as well. This seems to be legacy in some way, because freshly created plugins with grails 2.3.2 dont have references to tomcat. So I just removed all references from the plugins and kept the flag switch in my main application.

Just a slight clarification, which was mentioned aboveby chubbsondubs, but which I missed on first read...

Usually the simple answer to this is instead of doing:

grails run-script scripts/DoSomething

just do this:

grails do-something

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM