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

我是研究僧i 提交于 2019-11-28 18:59:47

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.

Try change the tomcat build type in buildConfig.groovy to compile instead of 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!