Skip to content

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

The java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException error occurs when the Java class javax.xml.bind.JAXBException is not found on the classpath. This class is part of the Java Architecture for XML Binding (JAXB) API, which is used for parsing and generating XML.

Note: JAXB was removed from the default Java SE module path in Java 9 and remains an optional dependency that must be added explicitly. If you are using Java 9 or later, you must include the JAXB API in your project dependencies.

To fix the NoClassDefFoundError, you need to include the JAXB API on your classpath. Since Java 9, the JAXB API is not part of the standard Java SE module path, so you must add it explicitly. For modern projects (Jakarta EE 9+), use the jakarta.xml.bind namespace. For legacy projects (Java 8 and earlier), use the javax.xml.bind namespace.

For modern projects, it is recommended to use a build tool like Maven or Gradle instead of manually downloading JARs. Add the appropriate dependency to your pom.xml:

xml
<!-- Jakarta EE 9+ (Java 11+) -->
<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>4.0.2</version>
</dependency>

For legacy projects using Java 8, use the javax.xml.bind coordinates:

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

Build tools like Maven and Gradle automatically resolve and include these dependencies on the classpath when you run your application.

Dual-run preview — compare with live Symfony routes.