You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JWT method signWith(java.security.Key, io.jsonwebtoken.SignatureAlgorithm) is not found at runtime despite including all dependencies #38
Describe the bug
When using the stream-chat-java library, this error occurs at runtime (not during compile), even though all JWT dependencies are included:
java.lang.AbstractMethodError: Receiver class io.jsonwebtoken.impl.DefaultJwtBuilder does not define or inherit an implementation of the resolved method 'abstract io.jsonwebtoken.JwtBuilder signWith(java.security.Key, io.jsonwebtoken.SignatureAlgorithm)' of interface io.jsonwebtoken.JwtBuilder
The runtime error occurs when calling methods in the library "io.getstream" % "stream-chat-java", which uses JWT.
Stack trace of the error starting in the GetStream library:
java.lang.AbstractMethodError: Receiver class io.jsonwebtoken.impl.DefaultJwtBuilder does not define or inherit an implementation of the resolved method 'abstract io.jsonwebtoken.JwtBuilder signWith(java.security.Key, io.jsonwebtoken.SignatureAlgorithm)' of interface io.jsonwebtoken.JwtBuilder.
at io.getstream.chat.java.services.framework.DefaultClient.jwtToken(DefaultClient.java:153)
at io.getstream.chat.java.services.framework.DefaultClient.lambda$new$0(DefaultClient.java:98)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at io.getstream.chat.java.services.framework.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:170)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
at okhttp3.RealCall.execute(RealCall.java:81)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
at io.getstream.chat.java.services.framework.StreamServiceHandler.handle(StreamServiceHandler.java:18)
at io.getstream.chat.java.models.framework.StreamRequest.request(StreamRequest.java:24)
If I include the additional line in sbt (this dependency was not included above):
"io.jsonwebtoken" % "jjwt" % "0.9.1"
Then I get a different error:
java.lang.NoSuchMethodError: 'io.jsonwebtoken.JwtBuilder io.jsonwebtoken.JwtBuilder.signWith(java.security.Key, io.jsonwebtoken.SignatureAlgorithm)' at io.getstream.chat.java.services.framework.DefaultClient.jwtToken(DefaultClient.java:153) at io.getstream.chat.java.services.framework.DefaultClient.lambda$new$0(DefaultClient.java:98)
Expected behavior
Program should run successfully when calling JWT methods.
I found the problem. For anyone else using Java Play Framework, it is Java Play that includes the transitive dependency on com.typesafe.play:filters-helpers_2.12:2.8.11, which in turn brings in the JWT dependency on io.jsonwebtoken, which is not the implementation that GetStream depends on.
To fix the above error, io.jsonwebtoken needs to be excluded, not included as is described in the GetStream documentation. This is accomplished by putting excludeDependencies += "io.jsonwebtoken" % "jjwt" at the top level of build.sbt.
Why don't you want to include this dependency inside getstream library? Right now I have problems combining two different jwt dependencies. I need 0.9.1 in my project and you use 0.11.2
Activity
coderman2022 commentedon Jan 8, 2022
I found the problem. For anyone else using Java Play Framework, it is Java Play that includes the transitive dependency on
com.typesafe.play:filters-helpers_2.12:2.8.11, which in turn brings in the JWT dependency onio.jsonwebtoken, which is not the implementation that GetStream depends on.To fix the above error,
io.jsonwebtokenneeds to be excluded, not included as is described in the GetStream documentation. This is accomplished by puttingexcludeDependencies += "io.jsonwebtoken" % "jjwt"at the top level ofbuild.sbt.ferhatelmas commentedon Jan 8, 2022
It should be available in runtime. If a framework brings it in a different level, of course it should be excluded there to be included in runtime.
Good to hear you were able to get it worked.
bmitioglov commentedon Feb 4, 2023
Why don't you want to include this dependency inside getstream library? Right now I have problems combining two different jwt dependencies. I need 0.9.1 in my project and you use 0.11.2