Encountering ClassNotFoundException when trying to use Ring Jetty alongside Cognitect AWS-api in Clojure

149 Views Asked by At

I'm building a Ring-Jetty/Compojure app and there a situation where I have to interact with the AWS S3 API. So I decided to use Cognitect's aws-api for that. However, I'm encountering an issue when using it alongside Compojure with the Ring-Jetty adapter where it all just crashes down. When I remove the aws-api dependencies, these errors go away. I can't seem to figure out what the conflict is though. Can somebody help me out?

The exception

My project.clj:

(defproject my-app-server "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [hiccup "1.0.5"]
                 [ring/ring-anti-forgery "1.3.0"]
                 [org.clojure/data.json "1.0.0"]
                 [seancorfield/next.jdbc "1.1.547"]
                 [honeysql "1.0.444"]
                 [org.postgresql/postgresql "42.2.14"]
                 [crypto-password "0.2.1"]
                 [com.taoensso/carmine "2.19.1"]
                 [com.novemberain/langohr "5.1.0"]
                 [com.cognitect.aws/api "0.8.469"]
                 [com.cognitect.aws/endpoints "1.1.11.826"]
                 [com.cognitect.aws/s3 "799.2.682.0"]]
  :plugins [[lein-ring "0.12.5"]]
  :ring {:handler my-app-server.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})
1

There are 1 best solutions below

0
jaihindhreddy On

ClassNotFound exception usually means the right dependency is not on the classpath, or there's a typo in what you're trying to require. In this case, the ring-jetty-adapter lib was missing. Because you're using leiningen, you can add [ring/ring-jetty-adapter "1.8.1"] to your :dependencies to fix it.

lein classpath and lein deps :tree are useful tools to debug things like this.