0

当我将项目升级到 grails 2.0(使用全新安装的可搜索插件)时,我得到一个 Hibernate 类转换异常。还有其他人遇到这个问题吗?

4

5 回答 5

2

http://grails.org/使用 Searchable 插件,它适用于 Grails 2.0.3。你遇到了什么问题?

于 2012-05-24T21:53:19.590 回答
1

将我的应用程序从 Grails 1.3.7 迁移到 2.1.1 遇到了类似的问题。我能够通过将 Searchable 插件从 0.5.5 更新到 0.6.4 来解决它。

这是堆栈跟踪的样子:

| Error 2012-10-05 19:02:18,691 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: org.codehaus.groovy.grails.orm.hibernate.SessionFactoryProxy cannot be cast to org.hibernate.impl.SessionFactoryImpl
Message: org.codehaus.groovy.grails.orm.hibernate.SessionFactoryProxy cannot be cast to org.hibernate.impl.SessionFactoryImpl
Line 
| Method 
->>  95 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityLifecycleInjector
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    46 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityCollectionLifecycleInjector
|   149 | doStart . . . . in org.compass.gps.device.hibernate.HibernateGpsDevice
|   125 | start           in org.compass.gps.device.AbstractGpsDevice
|    73 | start . . . . . in org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
|   166 | start           in org.compass.gps.impl.AbstractCompassGps
|   144 | doCall . . . .  in SearchableGrailsPlugin$_closure3
|   303 | innerRun        in java.util.concurrent.FutureTask$Sync
|   138 | run . . . . . . in java.util.concurrent.FutureTask
|   886 | runTask         in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . in     ''
^   680 | run             in java.lang.Thread
| Error 2012-10-05 19:02:18,715 [localhost-startStop-1] ERROR [localhost].[/myApp]  - Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
Message: Error executing bootstraps; nested exception is java.lang.ClassCastException: org.codehaus.groovy.grails.orm.hibernate.SessionFactoryProxy cannot be cast to org.hibernate.impl.SessionFactoryImpl
Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   680 | run . .  in java.lang.Thread

Caused by ClassCastException: org.codehaus.groovy.grails.orm.hibernate.SessionFactoryProxy cannot be cast to org.hibernate.impl.SessionFactoryImpl
->>  95 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityLifecycleInjector
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    46 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityCollectionLifecycleInjector
|   149 | doStart  in org.compass.gps.device.hibernate.HibernateGpsDevice
|   125 | start    in org.compass.gps.device.AbstractGpsDevice
|    73 | start .  in org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
|   166 | start    in org.compass.gps.impl.AbstractCompassGps
|   144 | doCall . in SearchableGrailsPlugin$_closure3
|   303 | innerRun in java.util.concurrent.FutureTask$Sync
|   138 | run . .  in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . .  in     ''
^   680 | run      in java.lang.Thread
于 2012-10-09T11:15:41.257 回答
1

Searchable 基于Compass被重写为ElasticSearch

ElasticSearch插件适用Grails 2.0。

有关更多信息,请参阅Compass 和 ElasticSearch 的未来

于 2012-02-13T20:50:20.570 回答
0

这是因为当您升级到使用 Hibernate 4.X 的 Grails 版本时。发生这种情况是因为 Hiberate 3.x 和 4.x 之间有几个包名和类名更改,因此适用于 Hibernate 3.x 的代码将不适用于 4.x,除非在极少数情况下。除了名称更改之外,内部工作方式也发生了很大变化,因此编译的代码不一定会运行。应用程序选项 #1 是降级到 Hibernate 3.x。包含并注释掉的配置设置(BuildConfig.groovy、DataSource.groovy),所以这是一个非常快速的选项。如果您依赖于 4.x 中添加的功能,显然不是一个选项,这只会延迟真正的问题,直到您必须升级 Hibernate。

于 2014-11-18T19:06:48.283 回答
0

是的,我也在 grails 1.3.7 、 2.0.3 上使用 searchable ,现在在 2.1.1 上使用

我所要做的就是将我的可搜索插件升级到最新的。虽然我不得不对代码进行一些调整,但插件文档中提到了每一件事

文档链接

注意控制器中的导入。我猜类路径已经改变。这是我所做的唯一改变。

于 2012-11-27T11:23:48.307 回答