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 ]
Open a command prompt. Run the JAXB schema compiler, xjc command from the directory where the schema file is located. The xjc schema compiler tool is located in the app_server_root \bin\ directory. Use the generated JAXB objects within a Java application to manipulate XML content through the generated JAXB classes.
JAXB Binding Compiler. Contains source code needed for binding customization files into java sources. In other words: the *tool* to generate java classes for the given xml representation. License.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With