Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter Java 11

Tags:

java

java-11

jwt

I have an API that receives a JWT token for authorization.

Once it starts the process of working with the token to authenticate it throws this error: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter

I read that in Java 11 they removed the java.xml.bind library from the JDK. I added these two dependencies as suggested in the answer: implementation "jakarta.xml.bind:jakarta.xml.bind-api:3.0.0" and implementation "org.glassfish.jaxb:jaxb-runtime:3.0.0".

Also tried implementation "jakarta.xml.bind:jakarta.xml.bind-api:3.0.0" and implementation 'com.sun.xml.bind:jaxb-impl:3.0.0'.

But I still get the same error and I cannot find any other solution to this.

I use Java 11 and Spring boot 2.6.6.

Thanks for the help

like image 631
andreootid Avatar asked Oct 18 '25 12:10

andreootid


2 Answers

i solved this problem by removing old jjwt 0.9.1 and add these

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
like image 198
Amin garo Avatar answered Oct 21 '25 00:10

Amin garo


As @andréootide said JJWT needs DatatypeConverter from javax.xml.bind..... I solved my problem by adding

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
like image 37
Ballo Ibrahima Avatar answered Oct 21 '25 02:10

Ballo Ibrahima



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!