Problem::JavaReflectionManager cannot be cast to MetadataProviderInjector
Using Hibernate annotation, after upgraded Hibernate version from v3.2.7 to v3.6, it hits following error message :
Caused by: java.lang.ClassCastException:
org.hibernate.annotations.common.reflection.java.JavaReflectionManager
cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector
Here’s the list of the Hibernate annotation libraries :
- hibernate3-3.6.0.Final.jar
- hibernate-annotations-3.4.0.GA.jar
- hibernate-commons-annotations-3.0.0.GA.jar
Solution
Hibernate annotation module is merged into Hibernate core module since v3.5 (if not mistake). In this case, Hibernate is detected two annotation modules, from both “Hibernate core” and “Hibernate annotation“, causing conflict and prompt the ClassCastException
.
To fix it, just delete both of the hibernate-annotations-3.4.0.GA.jar
and hibernate-commons-annotations-3.0.0.GA.jar
, because latest Hibernate core library is able to perform annotation task without other dependency.