Reputation: 402
This used to work with all previous versions of JAXB. I've upgraded to version 2.2.7 of JAXB and now xjc
throws the following:
java.lang.AssertionError: javax.xml.bind.JAXBException - with linked exception: [com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
com.sun.xml.bind.api.impl.NameConverter is an interface, and JAXB can't handle interfaces. this problem is related to the following location: at com.sun.xml.bind.api.impl.NameConverter at public com.sun.xml.bind.api.impl.NameConverter com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding.nameConverter at com.sun.tools.xjc.reader.xmlschema.bindinfo.BIGlobalBinding ]
Upvotes: 7
Views: 9031
Reputation: 14429
As the whole JAXB project now moved from https://github.com/javaee/jaxb-v2 to https://github.com/eclipse-ee4j/jaxb-ri including the Maven dependencies, I updated my pom.xml
from
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb-xjc.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
to
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb-xjc.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
This helped me at least with a similar issue.
Upvotes: 2
Reputation: 2403
Assumed that you are using Eclipse or a derivative (websphere studio, jDeveloper, Spring Tools Suite, ...). If not, you may use the JDK 'xjc' command line tool, else the Maven Plug-in JAXB2)
You have to explicitly configure JAXB for the project (different projects may bear different configs to make things simple!)
In recent Eclipse version (4.4+) follow these steps:
Upvotes: 1
Reputation: 402
As of jaxb 2.2.7 they have split the jaxb libraries into several components. xjc is now decoupled from any particular jaxb runtime. To fix this issue, ensure a jaxb runtime is made available on the classpath when executing xjc. Details can be found on their release notes here: https://jaxb.java.net/nonav/2.2.7/docs/release-documentation.html#a-2-2-7
The reference implementation can be found on maven central with the following coordinate: com.sun.xml.bind:jaxb-impl:2.2.7
Upvotes: 5