Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

解决方案:删除工程下hibernate-annotations3.4.jar及hibernate-commons-annotations3.3.jar,下载hibernate-annotation3.2.0.GA版本即可解决sessionFactory引用annotation冲突问题

 

java.lang.NoSuchMethodException

Code Block
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in FileHandler@1593936108/D:/jboss-eap-5.2/jboss-eap-5.2/jboss-as/server/default/tmp/a212a-uri5la-iwybsu0r-1-iwybtj2d-as/aeonlife_agent.war/ real=file:/D:/jboss-eap-5.2/jboss-eap-5.2/jboss-as/server/default/tmp/a212a-uri5la-iwybsu0r-1-iwybtj2d-as/aeonlife_agent.war/WEB-INF/classes/beans/application.xml: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)

网上给出了两种解决方案,一种就是在jboss的/common/lib的路径下将hibernate-annotation文件删除掉,这个方式不知道是否会对jboss产生影响,所以没有考虑,第二种方式就是在spring的hibernate的配置中添加以下两个属性配置: 

Xml代码  收藏代码Image Added
  1. <property name="hibernate.validator.apply_to_ddl">false</property>    
  2. <property name="hibernate.validator.autoregister_listeners">false</property>