gpt4 book ai didi

Grails 升级到 2.2.2 失败,迁移脚本出现 ClassNotFoundException

转载 作者:行者123 更新时间:2023-12-01 11:44:45 24 4
gpt4 key购买 nike

当我试图将我的 Grails 项目从 2.1.1 升级到 2.2.2 时,我得到了一个奇怪的堆栈跟踪,

| Error 2013-05-01 17:54:46,935 [localhost-startStop-1] ERROR context.GrailsContextLoader  - 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: devportal.schema.schema-0
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: devportal.schema.schema-0
Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run in ''
^ 680 | run . . in java.lang.Thread

Caused by GrailsConfigurationException: Class not found loading Grails application: devportal.schema.schema-0
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 138 | run in java.util.concurrent.FutureTask
| 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run in ''
^ 680 | run . . in java.lang.Thread

Caused by ClassNotFoundException: devportal.schema.schema-0
->> 202 | run in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 190 | findClass in java.net.URLClassLoader
| 306 | loadClass in java.lang.ClassLoader
| 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run . . in java.util.concurrent.FutureTask
| 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 918 | run . . in ''
^ 680 | run in java.lang.Thread

出于某种原因,它看起来像是在尝试从 Database Migrations plugin 运行我的数据库迁移.

我找到了一个 mailing list post关于这个问题,

It looks like I can actually add: package current to my migrations to fix the problem. Maybe I should have had this all along?

但是将我的包添加到我的脚本中并没有帮助(我什至尝试了 current)。

有人知道吗?

最佳答案

发帖后几乎直接找到了解决方案,

http://grails.1312388.n4.nabble.com/Nested-folder-for-database-migrations-in-Grails-2-2-x-td4642106.html

To follow up, I solved the problem by adding a package declaration to the beginning of the migration script files that matches the folder structure. Not sure if it's a Grails change or a Groovy change that caused the problem, but the files were being compiled into a the target/classes directory using the declared package structure (which in this case was nothing, resulting in them being at the root folder). However, Grails was detecting the files in the file structure and creating Spring FileSystemResources with paths to match that. These were passed to the DefaultGrailsApplication constructor and the ClassLoader failed to the find the classes at the matching locations.

grails-app/migrations/releases/release_1/foo.groovy -> target/classes/foo.class

By adding 'package releases.release_1' to the beginning of foo.groovy, then the following occurred:

grails-app/migrations/releases/release_1/foo.groovy -> target/classes/releases/release_1/foo.class

Then the ClassLoader found the corresponding class file for the FileSystemResource.

关于Grails 升级到 2.2.2 失败,迁移脚本出现 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16327231/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com