After migration of my jaxb code generator to jakarta, the unmarshalled xml is different

245 views Asked by At

After migrating jaxb dependencies to ones which use jakarta as detailed here: Java 11 package javax.xml.bind does not exist I am observing something strange.

I am using jaxb2-maven-plugin, version 2.5.0, which has one dependency xercesImpl 2.12.2.
The pom.xml has direct dependencies on jakarta.activation-api 1.2.2 & jakarta.xml.bind-api 2.3.3 and transitive dependencies on the org.glassfish.jaxb jaxb-runtime 2.3.8.

When I upgrade the jakarta.xml.bind-api to 3.0.1 and also try and upgrade the glassfish implementations, everything is generated seemingly correctly but the resulting xml is very different from what it was before.

The resulting XML has some peculiarities, for example it now contains the following mysterious tags

  • any
  • name
  • additionalName
  • otherAttributes
  • declaredType
  • scope

Where could these be coming from?

1

There are 1 answers

0
Laurent Schoelens On

Do you target jaxb jakarta's package based ?

I don't know much about jaxb2-maven-plugin (which is probably codehaus maven plugin) but the dependencies listed above are the javax based package dependencies.

The jaxb dependencies did the jakarta move in v3 (jakartaee9, jdk8 based) and then in v4 they drop jdk8 support (jakartaee10 and jdk11 based).

If you want to generate java classes with jakarta's XML annotation, you should see if there's an updated version of the plugin that support this.

Another option is that you can try using the jaxb-tools maven plugin : it should be easy to switch from one plugin to another since they share some config parameters.

One note :

  • v2 is for jaxb 2.3
  • v3 is fof jaxb 3
  • v4 is for jaxb 4 and requires jdk11 as minimal runtime