Class 为 Grails 数据库迁移文件将 grails 升级到 2.5.0 时出现 Not Found 错误
Class Not Found errors when upgrading grails to 2.5.0 for Grails database migrations files
我正在尝试将 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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 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 无关 - 问题是 upgrade-2.1
不是 Groovy 脚本的有效名称。您只能使用有效 class 名称的名称。您必须将句点替换为另一个字符,也可能是破折号。试试 upgrade_2_1.groovy
.
我正在尝试将 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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 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 无关 - 问题是 upgrade-2.1
不是 Groovy 脚本的有效名称。您只能使用有效 class 名称的名称。您必须将句点替换为另一个字符,也可能是破折号。试试 upgrade_2_1.groovy
.