【问题标题】:Class Not Found errors when upgrading grails to 2.5.0 for Grails database migrations files将 Grails 升级到 Grails 数据库迁移文件的 2.5.0 时出现 Class Not Found 错误
【发布时间】:2015-07-09 16:19:36
【问题描述】:

我正在尝试将 Grails 应用程序从 2.4.3 升级到 2.5.0 版本。 Grails 2.5.0 包含修复和改进,但没有任何重大更改。此外,安装了所有 2.5.0 兼容的插件版本。

还浏览了 Grails 数据库迁移插件更改日志和 支持 grails 2.5.0 的其他插件。 遇到我现在面临的相同 JIRA 问题 - Jira Link,但它已经在旧 Grails 数据库迁移插件版本中修复。

BuildConfig.groovy

grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.reload.enabled = true
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
    inherits("global") {
    }
    log "warn"
    checksums true // Whether to verify checksums on resolve

    repositories {
        inherits true // Whether to inherit repository definitions from plugins
        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()
        mavenRepo "http://repo.grails.org/grails/core" // Dependency for export plugin.
    }
    dependencies {
        compile ("org.apache.jclouds.provider:cloudfiles-us:1.6.2-incubating", "org.jclouds:jclouds-compute:1.6.0") {
            excludes "jclouds-core"
        }
        compile 'commons-beanutils:commons-beanutils:1.8.3'
        compile "org.apache.jclouds:jclouds-core:1.7.2"
        runtime 'mysql:mysql-connector-java:5.1.29'
    }

    plugins {
        runtime ':database-migration:1.4.0'
        runtime ":hibernate:3.6.10.18"
        runtime ":jquery:1.11.0.2"
        runtime ":resources:1.2.14"
        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        build ":tomcat:7.0.55.2"
    }
}

堆栈跟踪 我在默认迁移位置 grails-app/migrations 有一个名为 upgrade-2.1.groovy 的迁移文件

| Error 2015-04-30 10:52:09,868 [localhost-startStop-1] ERROR 
    context.GrailsContextLoaderListener  - Error initializing the 
    application: Error creating bean with name 'grailsApplication' 
    defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1
Message: Error creating bean with name 'grailsApplication' defined 
    in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    Invocation of init method failed; nested exception is 
    org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: 
    Class not found loading Grails application: upgrade-2.1

    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by GrailsConfigurationException: Class not found loading Grails application: upgrade-2.1
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

Caused by ClassNotFoundException: upgrade-2.1
->>  366 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run       in     ''
|    354 | findClass in java.net.URLClassLoader
|    425 | loadClass in java.lang.ClassLoader
|    262 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run       in java.lang.Thread

【问题讨论】:

    标签: grails database-migration grails-plugin


    【解决方案1】:

    这与插件或 Grails 无关 - 问题是 upgrade-2.1 不是 Groovy 脚本的有效名称。您只能使用有效类名的名称。您必须将句点替换为另一个字符,也可能是破折号。试试upgrade_2_1.groovy

    【讨论】:

    • 感谢@Burt 这么快的回复。通过从文件名中删除句点来修复错误。 upgrade-2.1.groovy -> upgrade_2_1.groovy
    • 文件名中的破折号也可以工作,我不必更改它们。前任。 upgrade-2_1.groovy.
    猜你喜欢
    • 2015-09-10
    • 2016-03-05
    • 2013-04-25
    • 2011-01-07
    • 1970-01-01
    • 2013-08-21
    • 1970-01-01
    • 2014-07-24
    相关资源
    最近更新 更多