Technology3 min read

[SOLVED] java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 11

Abhishek Ahlawat

By Abhishek Ahlawat โ€” Recently

Founder of StudyTonight and a MERN fullstack developer. Writes about JavaScript, web development, Linux, and tech.

Summarize this article using AI

If you are upgrading your Java application from a lower version to Java 11, you may get the following error:

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
...
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
...
...
...

The JAXB APIs are considered to be Java EE APIs, and therefore are no longer contained on the default class path in Java SE 9. In Java 11 they are completely removed from the JDK. If you are using Java 9, then the JAVA SE module named java.se is in the classpath but this module doesn't contain the JAVA EE APIs. While from Java 11 onwards, the jaxb apis, namely:

  1. jaxb-api

  2. jaxb-core

  3. jaxb-impl

  4. activation, etc

are completely removed from the Java installation. Hence, to resolve the above error, you must include the jaxb-api jar file in the classpath of your project/application.


For Maven Projects:

If you are using Maven for handling dependencies in your Java project, you will have to add the following additional dependency in your pom.xml file.

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

This will include the jaxb-api Jar file in your project when you will build your maven java project.


For Gradle Projects:

If you use Gradle to build your project, then add the following line to your build.gradle file,

compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'

For SBT Projects:

If you use SBT build tool to compile and build your java project, then add the following line to your build file,

libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"

For IVY Projects:

If you use ivy for building your java project, then add the following code line to your ivy.xml file:

<dependency org="javax.xml.bind" name="jaxb-api" rev="2.3.0"/>

If you don't use any build tool

If you are not using any build tool, then you can download the jar file from the following link: JAXB-API 2.3.0 MVN Repository and add it to your project's classpath


Once you have made the following changes, restart your Java application and the error should be resolved. So this was the solution for the java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException Error. If you are not able to understand anything, feel free to comment and we will help you resolve your error.


SHARE YOUR THOUGHTS WITH US!


Spotted something outdated or wrong?

Liked this? See more StudyTonight posts in Google results.

Add StudyTonight as a preferred source
Next questLIVE OPSStep 2 / 3

Practice real incidents in the browser

System Design Ops โ€” put out fires, ship fixes, and stack XP. Reading done. Time to play.

Play System Design
  • +XP

    Every sim

  • Incidents

    Live ops

  • Ranks

    Climb up

Read next