[Solved] java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
- Details
- Written by Nam Ha Minh
- Last Updated on 11 May 2019   |   Print Email
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:
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:
Then restart the server, the error will go way.
That's the solution to fix the error java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException.
Comments