In Java web application development, you may encounter the following error when starting the server (e.g. Apache Tomcat):

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
...
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
...
...
...
This error would look something like this in Eclipse IDE:

JAXBException error

It is because the JAXB library (Java Architecture for XML Binding) is missing in the classpath. JAXB is included in Java SE 10 or older, but it is removed from Java SE from Java 11 or newer –moved to Java EE under Jakarta EE project.

That means if you encounter JAXBException error, it’s very much likely that you are using Java 11 or newer for your project – or at least the server is running under on that Java version. So to fix this error, you have to options:

1. Use older Java version like JDK 8, 9 or 10 which still include the JAXB library by default. Or:

2. Specify an additional dependency in your project’s pom.xml file as follows:

<dependency>
	<groupId>javax.xml.bind</groupId>
	<artifactId>jaxb-api</artifactId>
	<version>2.3.0</version>
</dependency>
In case you don’t use Maven, you can manually download the JAXB JAR file from Maven repository, and add it to the project’s classpath:

Download JAXB JAR file



Then restart the server, the error will go way.

That's the solution to fix the error java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException.


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#21Nam2022-05-28 21:47
To Orlando Reyes: Try clean and rebuild the project, also update Maven project if you Eclipse; or refresh Maven if you use IntelliJ.
Quote
#20Orlando Reyes2022-05-28 10:25
I have already added the javax.xml.bind dependency as you suggest and the error java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException persists.
Quote
#19Nam2022-05-25 19:16
To KJ: Convert your project to use Maven to take its advantages of dependency management so you will get rid of such issue. Reference: www.youtube.com/watch?v=kpJLWugEseY
Quote
#18KJ2022-05-25 00:27
I downloaded the JAR file and placed in a path in linux machine, added then path to the Linux CLASSPATH variable but still unable to compile. Please share your idea.
Quote
#17Trần Công Việt2021-06-10 05:40
Thank you so much! ^^
Quote