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

huangapple go评论80阅读模式
英文:

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

问题

我正在构建一个 Ring-Jetty/Compojure 应用程序,有一个情况需要我与 AWS S3 API 进行交互。因此,我决定使用 Cognitect 的 aws-api 来实现。然而,在我将其与 Ring-Jetty 适配器一起使用时,出现了一个问题,整个应用程序都崩溃了。当我移除 aws-api 的依赖时,这些错误消失了。但我似乎无法弄清楚冲突在哪里。有人能帮我解决一下吗?

异常信息

我的 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"]]}})
英文:

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

得分: 1

ClassNotFound异常通常意味着正确的依赖项不在类路径上,或者在你尝试的require语句中有拼写错误。在这种情况下,缺少了ring-jetty-adapter库。因为你正在使用Leiningen,你可以将[ring/ring-jetty-adapter "1.8.1"]添加到你的:dependencies中来修复它。

lein classpathlein deps :tree是用来调试类似问题的有用工具。

英文:

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.

huangapple
  • 本文由 发表于 2020年7月26日 07:04:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63094462.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定