How to solve " Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException" When I run the same code with Java 15, at runtime I get errors indicating that
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:123)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
at com.hibernatedemo.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more
I added the pom.xml but it didn't work
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
I downloaded and built the "jaxb-api-2.3.0.jar" file separately and my problem was solved. Thank you very much, and also there is related to "pom.xml".
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
If anyone else encounters this problem, they can download the file from here. jaxb-api-2.3.0.jar