metosin / reitit

A fast data-driven routing library for Clojure/Script
https://cljdoc.org/d/metosin/reitit/
Eclipse Public License 1.0
1.43k stars 257 forks source link

Need dependency jackson-core for swagger-ui in reitit "0.3.10" #331

Closed MokkeMeguru closed 5 years ago

MokkeMeguru commented 5 years ago

Reproduction:

git clone -b jackson-dependency https://github.com/MokkeMeguru/tcs-handler/ 
cd tcs-handler
docker-compose run --service-port repl

# in docker
lein repl
task-cabinet-server.core=> (require '[reitit.swagger-ui :as swagger-ui])

if you removed the dependency, "[com.fasterxml.jackson.core/jackson-core "2.10.1"]", you got the below error.

Syntax error (ClassNotFoundException) compiling at (core.clj:1:1).
com.fasterxml.jackson.core.exc.InputCoercionException
miikka commented 5 years ago

Hi,

The problem is that your project is depending on Cheshire, which pulls in an older version of jackson-core (2.9.9) than the version of jackson-databind jsonista depends on (2.10.0). If the versions of jackson-core and jackson-databind do not match, you'll get problems like this. You can see the fully-resolved dependency tree by running lein deps :tree. Here's the result for your project without the explicit jackson-core dependency – look at the jackson versions:

 [buddy/buddy-hashers "1.4.0"]
   [buddy/buddy-core "1.6.0"]
     [commons-codec "1.12"]
     [net.i2p.crypto/eddsa "0.3.0"]
     [org.bouncycastle/bcpkix-jdk15on "1.62"]
     [org.bouncycastle/bcprov-jdk15on "1.62"]
   [clojurewerkz/scrypt "1.2.0"]
     [com.lambdaworks/scrypt "1.4.0"]
 [camel-snake-kebab "0.4.0"]
 [cheshire "5.9.0"]
   [com.fasterxml.jackson.core/jackson-core "2.9.9"]
   [com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.9.9"]
   [com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.9.9"]
   [tigris "0.1.1"]
 [cider/cider-nrepl "0.23.0-20191105.175422-4"]
 [clj-time "0.15.2"]
   [joda-time "2.10"]
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [com.fzakaria/slf4j-timbre "0.3.14"]
   [org.slf4j/slf4j-api "1.7.26"]
 [com.taoensso/timbre "4.10.0"]
   [com.taoensso/encore "2.91.0"]
     [com.taoensso/truss "1.5.0"]
     [org.clojure/tools.reader "0.10.0"]
   [io.aviso/pretty "0.1.33"]
 [environ "1.1.0"]
 [integrant "0.7.0"]
   [weavejester/dependency "0.2.1"]
 [integrant/repl "0.3.1"]
   [org.clojure/tools.namespace "0.2.11"]
 [metosin/reitit "0.3.10"]
   [metosin/reitit-core "0.3.10"]
     [meta-merge "1.0.0"]
   [metosin/reitit-dev "0.3.10"]
     [com.bhauman/spell-spec "0.1.1"]
     [expound "0.7.2"]
     [fipp "0.6.21" :exclusions [[org.clojure/core.rrb-vector]]]
   [metosin/reitit-frontend "0.3.10"]
   [metosin/reitit-http "0.3.10"]
   [metosin/reitit-interceptors "0.3.10"]
   [metosin/reitit-middleware "0.3.10"]
     [lambdaisland/deep-diff "0.0-47"]
       [mvxcvi/arrangement "1.2.0"]
       [mvxcvi/puget "1.1.2"]
       [org.clojure/core.rrb-vector "0.0.14"]
       [tech.droit/clj-diff "1.0.1"]
     [metosin/muuntaja "0.6.5"]
       [com.cognitect/transit-clj "0.8.319"]
         [com.cognitect/transit-java "0.8.337"]
           [javax.xml.bind/jaxb-api "2.3.0"]
           [org.msgpack/msgpack "0.6.12"]
             [com.googlecode.json-simple/json-simple "1.1.1" :exclusions [[junit]]]
             [org.javassist/javassist "3.18.1-GA"]
   [metosin/reitit-ring "0.3.10"]
     [ring/ring-core "1.7.1"]
       [commons-fileupload "1.3.3"]
       [commons-io "2.6"]
       [crypto-equality "1.0.0"]
       [crypto-random "1.2.0"]
       [ring/ring-codec "1.1.1"]
   [metosin/reitit-schema "0.3.10"]
     [metosin/schema-tools "0.12.0"]
       [prismatic/schema "1.1.11"]
   [metosin/reitit-sieppari "0.3.10"]
     [metosin/sieppari "0.0.0-alpha7"]
   [metosin/reitit-spec "0.3.10"]
     [metosin/spec-tools "0.10.0"]
   [metosin/reitit-swagger-ui "0.3.10"]
     [metosin/jsonista "0.2.5"]
       [com.fasterxml.jackson.core/jackson-databind "2.10.0"]
         [com.fasterxml.jackson.core/jackson-annotations "2.10.0"]
       [com.fasterxml.jackson.datatype/jackson-datatype-jsr310 "2.10.0"]
     [metosin/ring-swagger-ui "2.2.10"]
   [metosin/reitit-swagger "0.3.10"]
 [nrepl "0.6.0" :exclusions [[org.clojure/clojure]]]
 [org.clojure/clojure "1.10.0"]
   [org.clojure/core.specs.alpha "0.2.44"]
   [org.clojure/spec.alpha "0.2.176"]
 [ring-cors "0.1.13"]
 [ring-logger "1.0.1"]
   [org.clojure/tools.logging "0.3.1"]

Adding an explicit dependency on a newer version of jackson-core solves the problem in your project, but adding it to reitit-swagger-ui probably would not solve it. Unfortunately I don't think there's a bulletproof solution for library authors to force the versions to match. 😐

MokkeMeguru commented 5 years ago

Thanks your advice! I found chesire(https://github.com/dakrone/cheshire) will correspond to jackson-core 2.10.0 soon. So I'll wait a moment.