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

Clean solution for all JDKs >= 9

You need to add two dependencies to your build

  • the jaxb-api
  • a jaxb implementation

As an implementation I chose to use the reference implementation by glassfish to get rid of old com.sun classes / libraries. So as a result I added in my maven build

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

<dependency>
  <groupId>org.glassfish.jaxb</groupId>
  <artifactId>jaxb-runtime</artifactId>
  <version>2.3.1</version>
</dependency>

Note that from version 2.3.1 you don't need to add the javax.activation any longer. (see https://github.com/eclipse-ee4j/jaxb-ri/issues/1222)

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to jaxb

Java 11 package javax.xml.bind does not exist Java: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException Convert Java object to XML string no suitable HttpMessageConverter found for response type javax.xml.bind.UnmarshalException: unexpected element. Expected elements are (none) java.lang.VerifyError: Expecting a stackmap frame at branch target JDK 1.7 javax.xml.bind.JAXBException: Class *** nor any of its super class is known to this context How to generate JAXB classes from XSD? convert xml to java object using jaxb (unmarshal) I can't understand why this JAXB IllegalAnnotationException is thrown

Examples related to java-9

what is an illegal reflective access Error occurred during initialization of boot layer FindException: Module not found Failed to run sdkmanager --list with Java 9 Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema" Java: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Examples related to java-11

Error: Java: invalid target release: 11 - IntelliJ IDEA How to install OpenJDK 11 on Windows? How to install JDK 11 under Ubuntu? Java 11 package javax.xml.bind does not exist IntelliJ can't recognize JavaFX 11 with OpenJDK 11 Unable to compile simple Java 10 / Java 11 project with Maven Java: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Examples related to java-10

Unable to compile simple Java 10 / Java 11 project with Maven Java: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException