question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find an implementation for interface io.jsonwebtoken.io.Serializer ... in fat jar

See original GitHub issue

Hi guys,

We are seeing this error: Unable to find an implementation for interface io.jsonwebtoken.io.Serializer using java.util.ServiceLoader. Ensure you include a backing implementation .jar in the classpath, for example, jjwt-impl.jar, or your own .jar for custom implementations.

Of course, we’ve included all deps:

     implementation 'io.jsonwebtoken:jjwt-api:0.11.0'
     implementation 'io.jsonwebtoken:jjwt-impl:0.11.0'
     implementation 'io.jsonwebtoken:jjwt-gson:0.11.0'

We are using a fat jar (all jars merged into one big jar). I’ve checked and the classes are present in our fat jar:

$ jar tf releases/server-1.20.42.jar | grep jsonwebtoken.*Serializer
io/jsonwebtoken/io/JacksonSerializer.class
io/jsonwebtoken/gson/io/GsonSerializer.class
io/jsonwebtoken/io/Serializer.class

There’s something I’m missing because this class is loaded using the standard ServiceLoader which says:

A service provider is identified by placing a provider-configuration file in the resource directory META-INF/services. The file’s name is the fully-qualified binary name of the service’s type.

Well, I can see any such file in the jjwt-gson:

$ mkdir temp; cd temp
$ jar xf ~/.gradle/caches/modules-2/files-2.1/io.jsonwebtoken/jjwt-gson/0.11.0/8042478d4d0024aa4edb0d608475093acfc7f3e8/jjwt-gson-0.11.0.jar
$ find -type f
./io/jsonwebtoken/gson/io/GsonSerializer.class
./io/jsonwebtoken/gson/io/GsonDeserializer.class
./META-INF/MANIFEST.MF
./META-INF/maven/io.jsonwebtoken/jjwt-gson/pom.xml
./META-INF/maven/io.jsonwebtoken/jjwt-gson/pom.properties

So I’m not sure how this is supposed to work.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
masterdany88commented, Jun 4, 2020

Hi. I have same issue while working with war package. I have jjwt-impl-0.11.1.jar and jjwt-api-0.11.1.jar inside App-server-0.0.2-SNAPSHOT.war\WEB-INF\lib
But tomcat prints error: 04-Jun-2020 19:55:53.156 SEVERE [http-nio-9000-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [com.qiagen.qbase.qbap.server.conf.RestConfig] in context with path [] threw exception [io.jsonwebtoken.lang.UnknownClassException: Unable to find an implementation for interface io.jsonwebtoken.io.Serializer using java.util.ServiceLoader. Ensure you include a backing implementation .jar in the classpath, for example jjwt-impl.jar, or your own .jar for custom implementations.] with root cause io.jsonwebtoken.impl.lang.UnavailableImplementationException: Unable to find an implementation for interface io.jsonwebtoken.io.Serializer using java.util.ServiceLoader. Ensure you include a backing implementation .jar in the classpath, for example jjwt-impl.jar, or your own .jar for custom implementations. at io.jsonwebtoken.impl.lang.Services.loadFirst(Services.java:105) at io.jsonwebtoken.impl.lang.LegacyServices.loadFirst(LegacyServices.java:21) at io.jsonwebtoken.impl.DefaultJwtBuilder.compact(DefaultJwtBuilder.java:300) at com.app.adapter.jwt.JwtAdapter.create(JwtAdapter.java:43)

UPDATE

Oh. Ive added:

<dependency>
    <groupId>io.jsonwebtoken</groupId>
    <artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
    <version>0.11.1</version>
    <scope>runtime</scope>
</dependency>

and now it works.

8reactions
darioseidlcommented, Aug 13, 2021

Is a serializer JAR (for Jackson or Gson) required?

Like @mbogner said,

With 0.11.2 I got the same error that impl couldn’t be found. Adding the jackson lib as stated above solved that problem for me as well.

with 0.11.2 I’m also seeing this error unless I include the Jackson or Gson jar and the error message is misleading as it says that the jjwt-impl.jar is missing, but it’s actually the jjwt-jackson.jar that was missing in my case:

    implementation("io.jsonwebtoken:jjwt-api:0.11.2")
    runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")

results in:

Unable to find an implementation for interface io.jsonwebtoken.io.Serializer using java.util.ServiceLoader. Ensure you include a backing implementation .jar in the classpath, for example, jjwt-impl.jar, or your own .jar for custom implementations

but this works:

    implementation("io.jsonwebtoken:jjwt-api:0.11.2")
    runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.2")
    runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.2")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot Reference Documentation
Check the spring.io web-site for a wealth of reference documentation. ... Executable jars (sometimes called “fat jars”) are archives containing your ...
Read more >
Fix list for IBM WebSphere Application Server Liberty
Fixes for WebSphere Application Server Liberty are delivered in fix packs periodically. This is a complete listing of all the fixes for Liberty...
Read more >
homebrew-core - Homebrew Formulae
a2ps 4.14 Any‑to‑PostScript filter aacgain 1.8 AAC‑supporting version of mp3gain aalib 1.4rc5 Portable ASCII art graphics library aamath 0.3 Renders mathematical expressions as ASCII art
Read more >
Table of Contents - Micronaut Documentation
Implement the AnnotationMapper interface. Define a META-INF/services/io.micronaut.inject.annotation.AnnotationMapper file referencing the implementation class.
Read more >
Package List — Spack 0.17.1 documentation
Aluminum also contains custom implementations of select algorithms to optimize ... for data coupling between packages in-core, serialization, and I/O tasks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found