Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the JAXB Jar files to be used with Java 17 project

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.

like image 464
Anjit Singha Avatar asked Dec 02 '25 09:12

Anjit Singha


2 Answers

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>
like image 191
zforgo Avatar answered Dec 05 '25 00:12

zforgo


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>
like image 42
eda Avatar answered Dec 05 '25 00:12

eda