Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

After installing JDK9, I get this exception when running my Scala projects. Upgrading Scala to 2.12.2 also didn't resolve my problem.

like image 297
abshar Avatar asked Mar 23 '17 03:03

abshar


People also ask

How do you fix No Class Def Found error?

lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.

What is JAXB exception?

This exception indicates that an error has occurred while performing a validate operation. Methods in javax.xml.bind that throw JAXBException. Modifier and Type. Method and Description. abstract Marshaller.

What is @XmlElement in Java?

Maps a JavaBean property to a XML element derived from property name. Usage. @XmlElement annotation can be used with the following program elements: a JavaBean property. non static, non transient field.

What is JAXB in Java?

JAXB simplifies access to an XML document from a Java program by presenting the XML document to the program in a Java format. The first step in this process is to bind the schema for the XML document into a set of Java classes that represents the schema.


2 Answers

You can add dependencies in maven

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>
like image 50
Henboter Avatar answered Sep 27 '22 20:09

Henboter


The java.xml.bind module is not resolved by default when running code on the module path. This means that if you depend on JAXB then you need to run with --add-modules java.xml.bind or else deploy JAXB on the class path (or module path).

Update: The "Modules Shared with Java EE Not Resolved by Default" section of JDK 9 Migration Guide provides more information on this topic.

like image 32
Alan Bateman Avatar answered Sep 27 '22 19:09

Alan Bateman