Hiep Le
Hiep Le

Reputation: 373

Elastic4s. Scala module requires Jackson Databind version

My project use Play framework ver 2.4.11, Scala ver 2.11.12

I am trying integrated elastic4s into my project. this is sbt log when I add "com.sksamuel.elastic4s" %% "elastic4s-client-esjava" % "7.0.0" into build.sbt

[info] Resolving com.fasterxml.jackson.core#jackson-databind;2.11.0 
...
[info] Resolving com.fasterxml.jackson.core#jackson-databind;2.5.4

Seem like jackson ver 2.11.0 belong to elastic4s

But when this code run

client.execute {
      indexInto(s"access").fields(
        "uri" -> request.uri,
        "time" -> requestTime
      )
    }

I got an error

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Scala module 2.9.8 requires Jackson Databind version >= 2.9.0 and < 2.10.0
    at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:61) ~[jackson-module-scala_2.11-2.9.8.jar:na]
    at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:17) ~[jackson-module-scala_2.11-2.9.8.jar:na]
    at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:818) ~[jackson-databind-2.11.0.jar:2.11.0]
    at com.sksamuel.elastic4s.JacksonSupport$.<init>(JacksonSupport.scala:12) ~[elastic4s-core_2.11-7.0.0.jar:7.0.0]
    at com.sksamuel.elastic4s.JacksonSupport$.<clinit>(JacksonSupport.scala) ~[elastic4s-core_2.11-7.0.0.jar:7.0.0]

I add "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" into build.sbt but nothing happen

Please help me fix it. Thank you

Upvotes: 0

Views: 1784

Answers (1)

Emiliano Martinez
Emiliano Martinez

Reputation: 4133

You can try to exclude transitive dependencies when importing Play like:

libraryDependencies += 
  "com.sksamuel.elastic4s" %% "elastic4s-client-esjava" % "7.0.0" exclude("com.fasterxml.jackson.core", "jackson-databind")

But maybe, elastic4s fails. Since that Play version is quite old, if the fix above does not work you will have to find a elastic4s version that supports the same version as the Play´s.

Upvotes: 1

Related Questions