Using the Apache cxf-xjc-plugin with Java 11 works fine, I am able to generate Java sources from xsd files. The problem comes when attempting to make use of those Java classes with JAXB: the available implementations of JAXB for Java 11 are org.glassfish.jaxb:jaxb-runtime or org.eclipse.persistence:org.eclipse.persistence.moxy, which both move all classes that were in package javax.xml.bind to jakarta.xml.bind. This is an issue because the Java classes generated by the cxf-xjc-plugin are annotated using the annotations in package javax.xml.bind.
Two potential solutions exist in my mind:
- Is there an implementation of JAXB (for Java 11) using the original
javax.xml.bindpackage? - Is there a way to configure cxf-xjc-plugin to use package
jakarta.xml.bindfor the generated class annotations?
You could use
maven-antrun-pluginto replacejavax.xml.bindwithjakarta.xml.bindin the generated files: