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:
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.
<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.
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'
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"
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 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.