使用hibernate注解的时候,jboss-4.2.3.GA异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener cannot be cast to org.hibernate.event.PreInsertEventListener
Caused by: java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener cannot be cast to org.hibernate.event.PreInsertEventListener
原因是:jboss-4.2.3.GA的server/default/lib已经有hibernate的注解包hibernate-annotations.jar了,而项目中的hibernate的注解包hibernate-annotations-3.3.0.ga.jar和jboss不同版本,导致冲突。
解决方法:把把jboss的hibernate-annotations.jar拷贝过来覆盖到项目的lib,问题解决。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener cannot be cast to org.hibernate.event.PreInsertEventListener
Caused by: java.lang.ClassCastException: org.hibernate.validator.event.ValidateEventListener cannot be cast to org.hibernate.event.PreInsertEventListener
原因是:jboss-4.2.3.GA的server/default/lib已经有hibernate的注解包hibernate-annotations.jar了,而项目中的hibernate的注解包hibernate-annotations-3.3.0.ga.jar和jboss不同版本,导致冲突。
解决方法:把把jboss的hibernate-annotations.jar拷贝过来覆盖到项目的lib,问题解决。