clojure - Schema causing uberimage build failure -
i'm developing simple hello world web app in clojure. however, after added schema library project, started getting error below when trying build uberjar using lein uberjar
. strangely, app still passes unit tests , runs without errors when started using lein dev
.
java.lang.runtimeexception: unable resolve symbol: missing-required-key in context, compiling:(server/api.clj:21:17) @ clojure.lang.compiler.analyze(compiler.java:6464) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$vectorexpr.parse(compiler.java:3126) @ clojure.lang.compiler.analyze(compiler.java:6447) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$mapexpr.parse(compiler.java:2981) @ clojure.lang.compiler.analyze(compiler.java:6453) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$mapexpr.parse(compiler.java:2981) @ clojure.lang.compiler.analyze(compiler.java:6453) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.access$100(compiler.java:38) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6050) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$fnmethod.parse(compiler.java:5217) @ clojure.lang.compiler$fnexpr.parse(compiler.java:3846) @ clojure.lang.compiler.analyzeseq(compiler.java:6642) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$fnmethod.parse(compiler.java:5217) @ clojure.lang.compiler$fnexpr.parse(compiler.java:3846) @ clojure.lang.compiler.analyzeseq(compiler.java:6642) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.access$100(compiler.java:38) @ clojure.lang.compiler$defexpr$parser.parse(compiler.java:538) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler.compile1(compiler.java:7221) @ clojure.lang.compiler.compile(compiler.java:7292) @ clojure.lang.rt.compile(rt.java:398) @ clojure.lang.rt.load(rt.java:438) @ clojure.lang.rt.load(rt.java:411) @ clojure.core$load$fn__5066.invoke(core.clj:5641) @ clojure.core$load.doinvoke(core.clj:5640) @ clojure.lang.restfn.invoke(restfn.java:408) @ clojure.core$load_one.invoke(core.clj:5446) @ clojure.core$compile$fn__5071.invoke(core.clj:5652) @ clojure.core$compile.invoke(core.clj:5651) @ user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) @ user$eval9.invoke(form-init1857067608391167398.clj:1) @ clojure.lang.compiler.eval(compiler.java:6703) @ clojure.lang.compiler.eval(compiler.java:6693) @ clojure.lang.compiler.load(compiler.java:7130) @ clojure.lang.compiler.loadfile(compiler.java:7086) @ clojure.main$load_script.invoke(main.clj:274) @ clojure.main$init_opt.invoke(main.clj:279) @ clojure.main$initialize.invoke(main.clj:307) @ clojure.main$null_opt.invoke(main.clj:342) @ clojure.main$main.doinvoke(main.clj:420) @ clojure.lang.restfn.invoke(restfn.java:421) @ clojure.lang.var.invoke(var.java:383) @ clojure.lang.afn.applytohelper(afn.java:156) @ clojure.lang.var.applyto(var.java:700) @ clojure.main.main(main.java:37) caused by: java.lang.runtimeexception: unable resolve symbol: missing-required-key in context @ clojure.lang.util.runtimeexception(util.java:221) @ clojure.lang.compiler.resolvein(compiler.java:6940) @ clojure.lang.compiler.resolve(compiler.java:6884) @ clojure.lang.compiler.analyzesymbol(compiler.java:6845) @ clojure.lang.compiler.analyze(compiler.java:6427) ... 153 more exception in thread "main" java.lang.runtimeexception: unable resolve symbol: missing-required-key in context, compiling:(server/api.clj:21:17) @ clojure.lang.compiler.analyze(compiler.java:6464) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$vectorexpr.parse(compiler.java:3126) @ clojure.lang.compiler.analyze(compiler.java:6447) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$mapexpr.parse(compiler.java:2981) @ clojure.lang.compiler.analyze(compiler.java:6453) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$mapexpr.parse(compiler.java:2981) @ clojure.lang.compiler.analyze(compiler.java:6453) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.access$100(compiler.java:38) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6050) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$letexpr$parser.parse(compiler.java:6100) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$fnmethod.parse(compiler.java:5217) @ clojure.lang.compiler$fnexpr.parse(compiler.java:3846) @ clojure.lang.compiler.analyzeseq(compiler.java:6642) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$invokeexpr.parse(compiler.java:3719) @ clojure.lang.compiler.analyzeseq(compiler.java:6646) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler$bodyexpr$parser.parse(compiler.java:5782) @ clojure.lang.compiler$fnmethod.parse(compiler.java:5217) @ clojure.lang.compiler$fnexpr.parse(compiler.java:3846) @ clojure.lang.compiler.analyzeseq(compiler.java:6642) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyzeseq(compiler.java:6632) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.access$100(compiler.java:38) @ clojure.lang.compiler$defexpr$parser.parse(compiler.java:538) @ clojure.lang.compiler.analyzeseq(compiler.java:6644) @ clojure.lang.compiler.analyze(compiler.java:6445) @ clojure.lang.compiler.analyze(compiler.java:6406) @ clojure.lang.compiler.compile1(compiler.java:7221) @ clojure.lang.compiler.compile(compiler.java:7292) @ clojure.lang.rt.compile(rt.java:398) @ clojure.lang.rt.load(rt.java:438) @ clojure.lang.rt.load(rt.java:411) @ clojure.core$load$fn__5066.invoke(core.clj:5641) @ clojure.core$load.doinvoke(core.clj:5640) @ clojure.lang.restfn.invoke(restfn.java:408) @ clojure.core$load_one.invoke(core.clj:5446) @ clojure.core$compile$fn__5071.invoke(core.clj:5652) @ clojure.core$compile.invoke(core.clj:5651) @ user$eval9$fn__16.invoke(form-init1857067608391167398.clj:1) @ user$eval9.invoke(form-init1857067608391167398.clj:1) @ clojure.lang.compiler.eval(compiler.java:6703) @ clojure.lang.compiler.eval(compiler.java:6693) @ clojure.lang.compiler.load(compiler.java:7130) @ clojure.lang.compiler.loadfile(compiler.java:7086) @ clojure.main$load_script.invoke(main.clj:274) @ clojure.main$init_opt.invoke(main.clj:279) @ clojure.main$initialize.invoke(main.clj:307) @ clojure.main$null_opt.invoke(main.clj:342) @ clojure.main$main.doinvoke(main.clj:420) @ clojure.lang.restfn.invoke(restfn.java:421) @ clojure.lang.var.invoke(var.java:383) @ clojure.lang.afn.applytohelper(afn.java:156) @ clojure.lang.var.applyto(var.java:700) @ clojure.main.main(main.java:37) caused by: java.lang.runtimeexception: unable resolve symbol: missing-required-key in context @ clojure.lang.util.runtimeexception(util.java:221) @ clojure.lang.compiler.resolvein(compiler.java:6940) @ clojure.lang.compiler.resolve(compiler.java:6884) @ clojure.lang.compiler.analyzesymbol(compiler.java:6845) @ clojure.lang.compiler.analyze(compiler.java:6427) ... 153 more compilation failed: subprocess failed
below source file use schema. brevity, i've omitted rest of source files, if wants see rest, 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 name." :description "greets person name, telling them database configuration we're using 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 @ 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 tried disabling aot compilation, since seems main difference between normal compilation , building uberjar, no dice. looked 'missing-required-key' key in schema source code , made sure quoted properly, seems be, since if change schema's tests start failing.
what else different compilation process when creating uberjar compared compiling normally? there else can try?
the root cause swagger-docs
-route given 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, works expected.
still, given exception bad, , fixed in latest snapshot - uses defaults missing fields , not compile-time schema check it.
also, recommend not aoting whole app. see https://github.com/metosin/compojure-api/issues/129
Comments
Post a Comment