2012-02-13 68 views
0

當我升級到grails 2.0項目(全新安裝可搜索插件)時,我得到了一個Hibernate類拋出異常。其他人是否會遇到這個問題?可搜索插件可用於Grails 2.0.0嗎? (我認爲不是)

+2

我在Grails 2.0.0應用程序中使用可搜索插件,它工作正常。如果你想獲得更多有用的幫助,我建議你發佈相關的代碼 – 2012-02-14 09:49:20

+0

如果你告訴我們你正在得到一個異常,那麼我們希望看到堆棧跟蹤。 – David 2012-05-24 22:57:55

回答

2

http://grails.org/使用Searchable插件,它適用於Grails 2.0.3。你遇到什麼問題?

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 
+0

是升級作品 – Wasim 2012-11-27 11:24:43

0

是我太習慣搜索上的Grails 1.3.7,2.0.3和現在使用的2.1.1

所有我需要做的就是升級我的可搜索插件到最新的一個。雖然我已在代碼中做了一些調整,但每一件事情是在插件文檔

link to documentation

介意控制器進口中提到。據我猜測,班級路徑已經改變。這是我做的唯一改變。

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。

相關問題