TestNG and Spring 3

一笑奈何 提交于 2019-11-30 20:27:30

Now the problem doesn't seem to be related to any of Spring or TestNG. The key part is:

 java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMappings has interface org.hibernate.cfg.Mappings as super class

Are you sure your CLASSPATH is OK? I.e. you have compatible version of Hibernate modules and no repetitions there?

What if you create a simple TestNG test that does the following:

Class.forName("org.hibernate.cfg.ExtendedMappings");

?

Your test ckass needs to extend AbstractTestNGSpringContextTests. Or if your code is testing database acces another useful class to extend is AbstractTransactionalTestNGSpringContextTests.

Consult the chapter on TestNG in the Spring documentation:

For me this problem was caused because I had different hibernate versions included myself, not because of a third party including them. A sweep of your project/poms to make sure you youserlf are only using one hibernate version is worthwhile.

You might want to try hibernate-annotations-3.5.0-Beta-1 as this aligns with hibernate-core-3.5.0-Beta-1.

I still get the java.lang.IncompatibleClassChangeError sometimes, as I'm trying to use hibernate search which is using the "old" annotations.

Also, not sure if you are running JBoss, but if you are you'll get this error with core 3.5.0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!