Schema causing uberimage build failure

152 views Asked by At

I'm developing a simple hello world web app in Clojure. However, after I added the Schema library to my project, I started getting the error below when trying to build an uberjar using lein uberjar. Strangely, the app still passes the unit tests and runs without errors when started using lein dev.

java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context, compiling:(server/api.clj:21:17) at clojure.lang.Compiler.analyze(Compiler.java:6464) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:538) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler.compile1(Compiler.java:7221) at clojure.lang.Compiler.compile(Compiler.java:7292) at clojure.lang.RT.compile(RT.java:398) at clojure.lang.RT.load(RT.java:438) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$compile$fn__5071.invoke(core.clj:5652) at clojure.core$compile.invoke(core.clj:5651) at user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) at user$eval9.invoke(form-init1857067608391167398.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.resolveIn(Compiler.java:6940) at clojure.lang.Compiler.resolve(Compiler.java:6884) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6845) at clojure.lang.Compiler.analyze(Compiler.java:6427) ... 153 more Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context, compiling:(server/api.clj:21:17) at clojure.lang.Compiler.analyze(Compiler.java:6464) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:3126) at clojure.lang.Compiler.analyze(Compiler.java:6447) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2981) at clojure.lang.Compiler.analyze(Compiler.java:6453) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6050) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6100) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3719) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:538) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644) at clojure.lang.Compiler.analyze(Compiler.java:6445) at clojure.lang.Compiler.analyze(Compiler.java:6406) at clojure.lang.Compiler.compile1(Compiler.java:7221) at clojure.lang.Compiler.compile(Compiler.java:7292) at clojure.lang.RT.compile(RT.java:398) at clojure.lang.RT.load(RT.java:438) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5066.invoke(core.clj:5641) at clojure.core$load.doInvoke(core.clj:5640) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5446) at clojure.core$compile$fn__5071.invoke(core.clj:5652) at clojure.core$compile.invoke(core.clj:5651) at user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) at user$eval9.invoke(form-init1857067608391167398.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6693) at clojure.lang.Compiler.load(Compiler.java:7130) at clojure.lang.Compiler.loadFile(Compiler.java:7086) at clojure.main$load_script.invoke(main.clj:274) at clojure.main$init_opt.invoke(main.clj:279) at clojure.main$initialize.invoke(main.clj:307) at clojure.main$null_opt.invoke(main.clj:342) at clojure.main$main.doInvoke(main.clj:420) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:383) at clojure.lang.AFn.applyToHelper(AFn.java:156) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.RuntimeException: Unable to resolve symbol: missing-required-key in this context at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.resolveIn(Compiler.java:6940) at clojure.lang.Compiler.resolve(Compiler.java:6884) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6845) at clojure.lang.Compiler.analyze(Compiler.java:6427) ... 153 more Compilation failed: Subprocess failed

Below is the source file where I use schema. For brevity, I've omitted the rest of my source files, but if anyone wants to see the rest, just ask.

(ns server.api
  (:require [aleph.http :as http]
            [compojure.api.sweet :refer :all]
            [compojure.route :as route]
            [com.stuartsierra.component :as component]
            [ring.middleware.reload :refer [wrap-reload]]
            [ring.util.http-response :refer :all]
            [schema.core :as s]
            [server.logging :refer [wrap-exception-logging wrap-request-logging] :as log]))

(s/defschema Greeting
  {:hello s/Str
   s/Keyword s/Any})

(defn app [db]
  (api
   {:format {:formats [:json-kw]}}
   (middlewares [wrap-request-logging
                 wrap-exception-logging]
                (swagger-ui "/docs" :swagger-docs "/endpoints")
                (swagger-docs "/endpoints"
                 {:info {:title "Hello World Api"}})

                (GET* "/greet" []
                      :summary "Greets someone by name."
                      :description "Greets a person by name, telling them about
                                    the database configuration we're using as well."
                      :return Greeting
                      :query-params [name :- s/Str]
                      (ok {:hello name :with-db db}))

                (route/not-found (not-found {:error "Page not found."})))))

(defrecord Api
  [port env db logger]
  component/Lifecycle

  (start [{:keys [connection] :as component}]
    (if connection
      component
      (do (log/info "Starting Api at port" port "with env" env)
          (let [application (app db)
                handler (if (= env :dev) (wrap-reload application) application)
                conn (http/start-server handler {:port port :join? false})]
            (assoc component :connection conn)))))

  (stop [{:keys [connection] :as component}]
    (if-not connection
      component
      (do (log/info "Stopping Api")
          (.close connection)
          (assoc component :connection nil)))))

(defn new-api [port env]
  (->Api port env nil nil))

I've already tried disabling AOT compilation, since that seems to be the main difference between normal compilation and building an uberjar, but no dice. I also looked for the 'missing-required-key' key in the Schema source code and made sure it is quoted properly, it definitely seems to be, since if I change it Schema's tests start failing.

What else is different about the compilation process when creating an uberjar compared to compiling normally? Is there anything else I can try?

4

There are 4 answers

0
Tommi Reiman On BEST ANSWER

The root cause is that the swagger-docs-route is given an invalid input (no :version given, see https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/swagger2_schema.clj#L13). When it's added, it works as expected.

Still, the given exception was really bad, and is fixed now in the latest SNAPSHOT - uses defaults for missing fields and thus does not do compile-time schema check for it.

Also, would recommend not AOTing the whole app. See https://github.com/metosin/compojure-api/issues/129

3
claj On

I did react on that you use :refer :all, it is preferred to use :refer [list of symbols used in code]. This probably not the error here, but it makes the code much easier to dive into for someone who don't know so much about the libraries.

I looked into the compojure.api.sweet-namespace and I see that Zach Tellmans Potemkin is used to "import" all functions from various namespaces into your namespace service.api. Maybe this renders problems when creating a jar.

Could you try to require the swagger-ui and swagger-docs from their original namespace by adding this row to the require?

[compojure.api.swagger swagger-ui swagger-docs]

If this doesn't work but at least gives another error message (maybe) try to require all the other symbols used explicitly.

0
CraigM On

I'm not sure if this will help, but try running lein deps :tree and see what the transitive dependencies are. It may be that multiple libraries are depending on different, incompatible versions of the same dependency. I've run into this before, but I have no idea why it would only happen when packaged in the uberjar.

1
Jason Wolfe On

I haven't seen that error before (and we deploy all of our services with schema and uberjar). It looks like line 21 is the swagger-docs middleware; can you try removing that and see if that fixes the issue?