• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAXBContext - IncompatibleClassChangeError  RSS feed

 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

Please help! What could be the problem?

I got the running time error for the following code:
JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );

ERROR:
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:106)
at com.evermind.naming.ContextClassLoader.defineClass(ContextClassLoader.java:993)
at com.evermind.naming.ContextClassLoader.findClass(ContextClassLoader.java:257)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.evermind.server.ApplicationContextClassLoader.findClass(ApplicationContextClassLoader.java:19)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at com.sun.xml.bind.ContextFactory_1_0_1.createContext(ContextFactory_1_0_1.java:45)
at java.lang.reflect.Method.invoke(Native Method)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:96)
at javax.xml.bind.ContextFinder.searchcontextPath(ContextFinder.java:229)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:149)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:281)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:238)

...
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.IncompatibleClassChangeError is the superclass of java.lang.InstantiationError amongst others. My guess (and it is a guess) would be that the class "com.acme.foo" doesn't exist. That's looks like a package name anyway, or something you've just left in out of an example (unless you changed it to post).

Hope that helps.

Jules
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't you get a ClassNotFoundException if the class didn't exist?
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, say what you mean Jules! :roll: I mean the class can't be instantiated, i.e. it's an abstract class or interface.

Jules
 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anybody use JAXB before? The method is as follows, it's
contextPath, not class:

static JAXBContext newInstance(java.lang.String contextPath)
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a similar error some time ago. In that case it was because I had compiled using a different library than the one I was using when I ran the program.

Looking closer on the error I would think that the class com.acme.foo implements an earlier (or later) version of the desired class.
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sarah Marsh:
Has anybody use JAXB before? The method is as follows, it's
contextPath, not class:

static JAXBContext newInstance(java.lang.String contextPath)


Heh, sorry 'bout that. Havent used JAXB; I was guessing based on the error you got. Either way I still think it has something to do with version incompatibility.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sarah,

Yes, sorry about the uninformed postings. I feel a sense of responsibility for making a mess of your thread.

Have you read the API doc entry for JAXBContext and the newInstance() method? There are a couple of references in there to jaxb.properties and the javax.xml.bind.context.factory property that might be the root of your problem.

Hope that goes some way towards making amends.

Jules
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!