What is a IncompatibleClassChangeError exception in Java?

心不动则不痛 提交于 2019-11-27 14:39:33

It means that at some point, an interface was changed to a class, but an implementer of the original interface was not modified and recompiled to accommodate this (incompatible) change.

For example, consider the following types:

interface Fooable {
  void foo();
}

class FooImpl implements Fooable {
  public void foo() {
     /* Do something... */
  }
}

Now suppose Fooable is modified and recompiled, but FooImpl is not:

abstract class Fooable {
  public abstract void foo();
}

JDK 1.4 support has been dropped in 3.6. So Hibernate Annotations has been merged back into Core and there is no more need to have both Configuration and AnnotationConfiguration and the later should not be used in 3.6.x (actually, you should probably use the JPA EntityManager, not the core API, but this is another story).

But my real advice would be to use the 3.5.x branch of Hibernate, not the 3.6.x. As we already saw, the Hibernate team is introducing big changes in 3.6, which is on top of that still in Beta, and unless you are following the changes closely, you'll face some surprises and won't find many resources on the internet yet. Just use Hibernate 3.5 (3.5.5-Final at the time of writing this).

Double check if all your libraries are compatible. Try the same with a stable version of hibernate, there's a chance that the beta is defect or the hibernate 3.6.0 beta POM has some incompatible dependencies.

Try to build it without maven and with hibernate 3.6.0 beta1 libraries from the official servers.


OK - your problem is not a bug but a new feature. The release notes for Hibernate 3.6.0 Beta2 note a major change to the previous beta: the AnnotationConfiguration is now totally deprecated. So you should (a) update to the most recent beta (Beta3) if you want to keep a 3.6.0 version and (b) do not continue using the AnnotationConfiguration.

Right, erickson has identified the issue correctly.

This is likely caused by having two conflicting versions of the same type definition in your classpath. For example, library-version2.jar defines some stuff, but you've also got library-version5.jar in your classpath.

At runtime, this results in the pain and suffering erickson describes.

I write this to help whoever lookup to this error . Sometimes jar files coming from Spring Roo generated pom.xml and Tomcat Server Runtime libraries conflict and produced this error during unit testing. While building frontend technology like Flex, Server runtime libraries are not necessary to present in the classpath, so simply remove the Server runtime libraries from classpath.

Which application server are you using? Could be a duplicate or conflicting hibernate jar.

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