duct 2024-04-22

Hi. I have an app that runs in the REPL and with lein run . The uberjar compiles but running it results in the following failure:

Exception in thread "main" java.lang.NoClassDefFoundError: clojure/core/cache/CacheProtocol
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)...
I have included CacheProtocol; here’s my project.clj:
(defproject com.yardwerkz/mobile-server "1.0.0-SNAPSHOT"
  :description "Server for mobile YardWerKz apps"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/tools.reader "1.4.2"]
                 [org.clojure/clojure "1.11.1"]
                 [com.taoensso/encore "3.98.0-RC9"]
                 [duct/core "0.8.1"
                  :exclusions [integrant
                               medley]]
                 [duct/module.ataraxy "0.3.0"
                  :exclusions [integrant]]
                 [duct/module.logging "0.5.0"
                  :exclusions [medley integrant]]
                 [duct/module.web "0.7.3"
                  :exclusions [medley
                               integrant
                               commons-codec
                               ring/ring-core]]
                 [com.yardwerkz/backend "0.1.0-SNAPSHOT"
                  :exclusions [io.aviso/pretty]]
                 [duct/server.http.http-kit "0.1.4"
                  :exclusions [http-kit]]
                 [http-kit "2.8.0-RC1"]
                 [com.rpl/specter "1.1.4"]
                 [com.stripe/stripe-java "24.7.0"]
                 [com.draines/postal "2.0.5"
                  :exclusions [commons-codec]]
                 [org.joda/joda-money "1.0.4"]
                 [org.clojure/core.async "1.6.681"
                  :exclusions [org.clojure/core.memoize
                               org.clojure/data.priority-map
                               org.clojure/core.cache]]
                 [org.java-websocket/Java-WebSocket "1.5.3"
                  :exclusions [org.slf4j/slf4j-api]]
                 [metosin/jsonista "0.3.8"
                  :exclusions [com.fasterxml.jackson.core/jackson-annotations]]
                 [net.sf.geographiclib/GeographicLib-Java "2.0"]
                 [com.cognitect.aws/api "0.8.692"
                  :exclusions [org.eclipse.jetty/jetty-http
                               org.eclipse.jetty/jetty-util
                               org.eclipse.jetty/jetty-io]]
                 [com.cognitect.aws/endpoints "1.1.12.504"]
                 [com.cognitect.aws/s3 "848.2.1413.0"]
                 [com.cognitect.aws/location "857.2.1574.0"]
                 [org.joda/joda-money "1.0.4"]
                 [ring "1.10.0" :exclusions [ring/ring-devel org.eclipse.jetty/jetty-http org.eclipse.jetty/jetty-io org.eclipse.jetty/jetty-server org.eclipse.jetty/jetty-util common-fileupload commons-fileupload crypto-equality commons-io org.slf4j/slf4j-api]]

                 [ring/ring-defaults "0.4.0"
                  :exclusions [ring/ring-core
                               crypto-equality]]
                 [org.eclipse.jetty/jetty-http "9.4.54.v20240208"]
                 [org.eclipse.jetty/jetty-util "9.4.54.v20240208"]
                 [org.eclipse.jetty/jetty-io "9.4.54.v20240208"]
                 [org.eclipse.jetty/jetty-server "9.4.54.v20240208"]
                 [io.aviso/pretty "1.4.4"]
                 [crypto-equality "1.0.1"]
                 [commons-fileupload "1.5"]
                 [org.clojure/core.cache "1.0.225"]
                 [org.clojure/core.memoize "1.1.266"]]

  :repositories [["releases" {:id "maven-releases"
                              :url ""}]
                 ["rama" {:url ""
                          :creds :gpg}]]

  :plugins [[duct/lein-duct "0.12.3"]]
  :main  com.yardwerkz.main
  :resource-paths ["resources" "target/resources"]
  :prep-tasks     ["javac" "compile" ["run" ":duct/compiler"]]
  :middleware     [lein-duct.plugin/middleware]
  :profiles
  {:dev  [:project/dev :profiles/dev]
   :repl {:prep-tasks   ^:replace ["javac" "compile"]
          :repl-options {:init-ns user}}
   :uberjar {:aot :all}
   :provided {:dependencies [[com.rpl/rama-prod "0.15.0"
                              :exclusions [medley
                                           instaparse
                                           ring/ring-core
                                           integrant
                                           compojure
                                           com.taoensso/encore]]]}
   :profiles/dev {}
   :project/dev  {:source-paths   ["dev/src"]
                  :resource-paths ["dev/resources"]
                  :dependencies   [[integrant/repl "0.3.2"
                                    :exclusions [integrant
                                                 org.clojure/java.classpath
                                                 org.clojure/tools.namespace]]
                                   [hawk "0.2.11"]
                                   [eftest "0.5.9"]
                                   [kerodon "0.9.1"
                                    :exclusions [ring/ring-codec]]]}})
I welcome any suggestions/comments/help you can offer! Thanks in advance.

How do you use CacheProtocol?

Do ns that uses CacheProtocol have clojure.core.cache import?

Solved this.

👍 1