Hibernateエラー:JavaReflectionManagerをMetadataProviderInjectorにキャストできません
問題
Hibernateアノテーションを使用して、Hibernateバージョンをv3.2.7からv3.6にアップグレードした後、次のエラーメッセージが表示されます。
Caused by: java.lang.ClassCastException: org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector
Hibernateアノテーションライブラリのリストは次のとおりです。
-
hibernate3-3.6.0.Final.jar
-
hibernate-annotations-3.4.0.GA.jar
-
hibernate-commons-annotations-3.0.0.GA.jar
溶液
Hibernate annotation module is merged into Hibernate core module since v3.5(間違いでない場合)。 この場合、Hibernateは「Hibernate core」と「Hibernate annotation」の両方から2つの注釈モジュールを検出し、競合を引き起こしてClassCastException
を促します。
これを修正するには、hibernate-annotations-3.4.0.GA.jar
とhibernate-commons-annotations-3.0.0.GA.jar
の両方を削除するだけです。これは、最新のHibernateコアライブラリが他の依存関係なしで注釈タスクを実行できるためです。