I am in the middle of upgrading my project from Java 8 to Java 17. My project use JAXB related JAR files. However, I am getting a lot of error while compiling the project and most of them are related to JAXB. Can anyone please help me with JAXB related JAR files and their version I should be using in my project for Java 17? Also, please suggest the compatible JAVA EE release I should be using.
In Java 8 and earlier, JAXB was integrated within JVM itself, but this was changed in Java 9. Because of the modularization of the JVM (Project Jigsaw), JAXB and some others were removed from JDK. This doesn't mean JAXB is no longer supported, just that it´s another dependency that needs to be on the classpath.
Due to JavaEE / Jakarta EE having breaking changes regarding namespace, the right dependency coordinates depends on what kind of enterprise specification is used.
In case of JavaEE 8 - the javax.* namespace - the correct dependency is:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
and the dependency compilant with JakartaEE - the jakarta.* namespace - is:
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
When i added the following dependencies, worked for Spring boot 3.1.4 and Java 17 version.
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.0</version>
</dependency>
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