Ruhezustand-Fehler: JavaReflectionManager kann nicht in MetadataProviderInjector umgewandelt werden
Problem
Bei Verwendung der Hibernate-Annotation wird nach dem Upgrade der Hibernate-Version vonv3.2.7 aufv3.6 die folgende Fehlermeldung angezeigt:
Caused by: java.lang.ClassCastException: org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector
Hier ist die Liste der Hibernate-Anmerkungsbibliotheken:
-
hibernate3-3.6.0.Final.jar
-
hibernate-annotations-3.4.0.GA.jar
-
hibernate-commons-annotations-3.0.0.GA.jar
Lösung
Hibernate annotation module is merged into Hibernate core module since v3.5 (wenn nicht Fehler). In diesem Fall werden im Ruhezustand zwei Anmerkungsmodule erkannt, sowohl von "Hibernate core" als auch von "Hibernate annotation", was zu Konflikten führt und dieClassCastException
auffordert.
Um dies zu beheben, löschen Sie einfach sowohlhibernate-annotations-3.4.0.GA.jar
als auchhibernate-commons-annotations-3.0.0.GA.jar
, da die neueste Hibernate-Kernbibliothek Annotationstasks ohne andere Abhängigkeit ausführen kann.