com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.14.3 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.0
Checklist
- [X] I have looked into the Readme and Examples, and have not found a suitable solution or answer.
- [X] I have looked into the API documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
using below jwks-rsa 0.22.1, scala 2.13.12
scalaVersion := "2.13.12"
libraryDependencies ++= Seq(
"com.github.jwt-scala" %% "jwt-play" % "10.0.0",
"com.github.jwt-scala" %% "jwt-core" % "10.0.0",
"com.auth0" % "jwks-rsa" % "0.22.1"
)
and play framework 3.0.1
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1")
when run the application, sbt run
it has exceptions like beow
[error] com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.14.3 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.0
see more details:
--- (Running the application, auto-reloading is enabled) ---
[error] com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.14.3 requires Jackson Databind version >= 2.14.0 and < 2.15.0 - Found jackson-databind version 2.15.0
[error] at com.fasterxml.jackson.module.scala.JacksonModule.setupModule(JacksonModule.scala:61)
[error] at com.fasterxml.jackson.module.scala.JacksonModule.setupModule$(JacksonModule.scala:46)
[error] at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:17)
[error] at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:879)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider$.$anonfun$configureObjectMapperModules$4(JacksonObjectMapperProvider.scala:252)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider$.$anonfun$configureObjectMapperModules$4$adapted(JacksonObjectMapperProvider.scala:251)
[error] at scala.collection.immutable.List.foreach(List.scala:333)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider$.configureObjectMapperModules(JacksonObjectMapperProvider.scala:251)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider$.createObjectMapper(JacksonObjectMapperProvider.scala:275)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider.create(JacksonObjectMapperProvider.scala:369)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider.$anonfun$getOrCreate$1(JacksonObjectMapperProvider.scala:327)
[error] at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
[error] at org.apache.pekko.serialization.jackson.JacksonObjectMapperProvider.getOrCreate(JacksonObjectMapperProvider.scala:327)
[error] at org.apache.pekko.serialization.jackson.JacksonJsonSerializer.
I had to add below as work around:
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.14.2"
inspired from this issue: https://github.com/jwt-scala/jwt-scala/issues/403
Qs:
- can this be avoided automatically moving forward? or does it have to be reported as issue, author of a lib does something to resolve it.
- I see https://mvnrepository.com/artifact/com.auth0/jwks-rsa/0.22.1 did pull in jackson-databind 2.15, hence above work around overrides this behavior.
Reproduction
see description add the dependency and playframework, run the application it hsa the run time error
Additional context
No response
jwks-rsa version
0.22.1
Java version
17.0.6
It's saying that for https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-scala_3/2.14.3 -- the jackson-databind dependency should also be 2.14.3.
For Play, it's probably better to upgrade everything to latest Jackson:
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.1",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.17.1",
Hi @minnieshi
Thanks for reporting this and for the detailed explanation — it's very helpful.
You're right: jwks-rsa 0.22.1 currently pulls in jackson-databind 2.15.0. This causes a runtime error when used with Play Framework 3.0.1, because jackson-module-scala 2.14.x requires jackson-databind **>=2.14.0 and <2.15.0`. As you've mentioned, overriding the Jackson version works:
dependencyOverrides += "com.fasterxml.jackson.core" % "jackson-databind" % "2.14.2"
Dependency conflicts like this are unfortunately common in mixed Java/Scala projects. But I'll also review other transitive dependencies to reduce potential version clashes.
Since users combine libraries in many ways, some conflicts may still require overrides or exclusions, especially when different libraries depend on different Jackson versions.
In coming future we will plan to upgrade to latest versions keeping the transitive dependencies conflict in vision.
Please feel free to ping me here in case of any queries and we will re-open this issue as needed.
Thanks again for the heads-up!