Fork me on GitHub
#portal
<
2021-10-18
>
richiardiandrea20:10:08

Hi folks, I am trying to set portal up but I get the following exception (cut for brevity):

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/JacksonFeatureSet
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
	at java.lang.Class.privateGetPublicMethods(Class.java:2902)
	at java.lang.Class.getMethods(Class.java:1615)
	at clojure.lang.Reflector.getMethods(Reflector.java:498)
	at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:996)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7107)
	... 143 more
Has anyone run into this before?

djblue20:10:10

Portal uses https://github.com/dakrone/cheshire (which I think uses jackson) for serialization. I wonder if you have a transitive dep that's causing a conflict :thinking_face:

richiardiandrea20:10:34

Yes it seems like I need to do this:

[djblue/portal "0.16.2" :exclusions [org.clojure/clojure
                                                                       org.clojure/spec.alpha
                                                                       org.clojure/core.specs.alpha
                                                                       com.fasterxml.jackson.core/jackson-annotations
                                                                       com.fasterxml.jackson.core/jackson-core
                                                                       com.fasterxml.jackson.core/jackson-databind]]

richiardiandrea20:10:14

actually no, it seems portal needs that old version

richiardiandrea20:10:51

or prolly we can bump portal 's deps

djblue20:10:16

When I run antq, only shadow-cljs is out-of-date

djblue20:10:42

cheshire/cheshire {:mvn/version "5.10.1"} is the current version

richiardiandrea20:10:55

I see - I actually copied [com.fasterxml.jackson.core/jackson-core "2.12.4"] at the top of my lein :dependencies and that worked

richiardiandrea20:10:19

let me try to specify portal's current version

djblue20:10:12

I wonder if the transitive dependency resolution between clj and lein is at play

richiardiandrea20:10:56

I found out the culprit there:

$ lein deps :tree
Possibly confusing dependencies found:
[metosin/muuntaja "0.6.7"] -> [metosin/jsonista "0.2.6"] -> [com.fasterxml.jackson.core/jackson-databind "2.11.0"]

seancorfield20:10:20

There's a reason we switched all of our app JSON dependencies to org.clojure/data.json and away from Cheshire/jsonista stuff! 🙂

☝️ 1
richiardiandrea20:10:56

oh well that's good to know 🤷

seancorfield20:10:03

I would say, for tooling, it really should avoid Cheshire/jsonista stuff if possible and rely on data.json -- to avoid conflicts.

djblue20:10:44

It should be pretty easy to make the switch 👌

djblue20:10:53

I'll try this out when I get some time

❤️ 2
seancorfield20:10:01

(several libs we rely on have an optional dependency on Cheshire and just disable JSON-related functionality if Cheshire isn't on the classpath -- and we rely on that disabling feature)

👍 1
seancorfield20:10:54

Now that data.json is so much faster than it used to be, I see no reason to use those other libraries -- unless you have absolutely critical bottleneck performance around JSON serialization in your app (and have profiled it and proved that is the problem).

seancorfield20:10:30

What annoys me is that so many libraries just drag these in as transitive deps in such a cavalier fashion 😞

seancorfield20:10:08

We just started using Hato (instead of httpkit) and I was disappointed to see its JSON support is conditional on Cheshire -- but at least it is conditional and we can just ignore it and do our own JSON stuff externally via data.json...

djblue20:10:09

Portal was using transit-clj/s for a long time for serialization but it also had issues with transitive deps. Looks like the safest option is going to be data.json

djblue01:10:48

My unscientific benchmark numbers say moving to data.json is reasonable:

1000000 runs, 36062 msecs, (cson/write v edn)
1000000 runs, 15864 msecs, (cson/write v cheshire)
1000000 runs, 14466 msecs, (cson/write v data-json)

1000000 runs, 17095 msecs, (cson/read v edn)
1000000 runs, 11041 msecs, (cson/read v cheshire)
1000000 runs, 14207 msecs, (cson/read v data-json)

1
richiardiandrea02:10:37

wow cool thanks for the quick turnaround, will try it right away 😄

gotta_go_fast 1
richiardiandrea03:10:19

works without any jackson-core override in the deps thank you!

awesome 1