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

时间:2013-05-01 22:02:49

标签: grails grails-2.2

尝试将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

  

看起来我实际上可以添加:        封装电流        我的迁移来解决问题。        也许我应该一直这样做?

但是将我的包添加到我的脚本没有帮助(我甚至试过current)。

有人有任何想法吗?

1 个答案:

答案 0 :(得分:5)

在发布后几乎直接找到解决方案,

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

  

为了跟进,我通过添加包声明解决了这个问题   与文件夹匹配的迁移脚本文件的开头   结构体。不确定是Grails更改还是Groovy更改   引起了这个问题,但文件被编译成了一个   目标/类目录使用声明的包结构(哪个   在这种情况下什么都没有,导致它们在根文件夹中)。   但是,Grails正在检测文件结构中的文件   使用与之匹配的路径创建Spring FileSystemResources。这些   被传递给DefaultGrailsApplication构造函数和   ClassLoader无法在匹配的位置找到类。

     

grails-app / migrations / releases / release_1 / foo.groovy - >   目标/类/让Foo.class

     

将'package releases.release_1'添加到foo.groovy的开头,   然后发生了以下情况:

     

grails-app / migrations / releases / release_1 / foo.groovy - >   目标/类/释放/ RELEASE_1 /让Foo.class

     

然后ClassLoader找到了相应的类文件   的FileSystemResource。