1

I use JJWT to mint JWTs. However, I get the following error:

"Unable to load class named [io.jsonwebtoken.impl.DefaultJwtBuilder] from the thread context, current, or system/application ClassLoaders. All heuristics have been exhausted. Class could not be found. Have you remembered to include the jjwt-impl.jar in your runtime classpath?"

I have included the jjwt-impl jar. Below is my gradle configuration:

api 'io.jsonwebtoken:jjwt-api:0.11.2'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2'
runtimeOnly('io.jsonwebtoken:jjwt-orgjson:0.11.2') {
    exclude group: 'org.json', module: 'json' 
}

Am i missing out something?

2 Answers2

1

Add these rules to your app proguard-rules.pro file will be solved the issue.

-keep class io.jsonwebtoken.** { *; }
-keepnames class io.jsonwebtoken.* { *; }
-keepnames interface io.jsonwebtoken.* { *; }

-keep class org.bouncycastle.** { *; }
-keepnames class org.bouncycastle.** { *; }
-dontwarn org.bouncycastle.**
Md Imran Choudhury
  • 9,343
  • 4
  • 62
  • 60
0

When I encountered this exception the issue was related to proguard.

In my case, I was able to fix it including the following rule inside the project's proguard-rules.pro file.

# Preserve all public classes, and their public fields and
# methods.
-keep public class * {
    public *;
}

Hope this helps!

sjgf
  • 1
  • 1