0

I am trying to make a sample web application on clojure that uses reitit and exposes its structure via swagger. To that end i have added code that handles request for "/swagger.json" as outlined in examples. Here is overall code: full file

Relevant sections are these:

(defn make-default-routes [] (ring/routes (ring/redirect-trailing-slash-handler) (ring/create-resource-handler {:path "/"}) (swagger-ui/create-swagger-ui-handler {:path "/swag"}) (ring/create-default-handler {:not-found (constantly {:status 404, :body (missing-page), :headers {}})}))) (defn make-app [system] (ring/ring-handler (ring/router [["/" {:get {:handler (constantly (resp/redirect "/landing"))} :swagger {:info {:title "wh-invasion"} :basePath "/"}}] ["/swagger.json" {:get {:no-doc true :handler (swagger/create-swagger-handler)}}] ["/landing" {:swagger {:tags ["user"]} :get {:handler (fn app [req] {:status 200 :headers {"Content-Type" "text/html"} :body (landing-page)})}}] ["/api" {:middleware [[wrap-json-body {:malformed-response {:status 400 :headers {"Content-Type" "text/plain"} :body "Malformed json in request"}}] wrap-json-response wrap-stacktrace [wrap-system system]] :swagger {:tags ["api"]}} ["/cards" ["/meta/:meta-param" {:get #(get-meta-parameter %) :put #(put-meta-parameter %)}]]] ["/admin" {:middleware [[wrap-system system]] :swagger {:tags ["admin"]}} ["/card" (fn [_req_] {:status 200 :headers {"Content-Type" "text/html"} :body (add-card-page)})]]]) (make-default-routes))) 

However when i try to access that route, i get the following exception (with stacktrace):

  1. Unhandled java.lang.NoClassDefFoundError

  2. Caused by java.lang.ClassNotFoundException reitit.ring.Endpoint$reify__4406

     ring.cljc: 16 reitit.ring.Endpoint/getLookupThunk 

    KeywordLookupSite.java: 52 clojure.lang.KeywordLookupSite/install

    KeywordLookupSite.java: 26 clojure.lang.KeywordLookupSite/fault

     REPL: 103 reitit.swagger/create-swagger-handler/create-swagger ring.cljc: 357 reitit.ring$ring_handler$fn__4583/invoke AFunction.java: 31 clojure.lang.AFunction$1/doInvoke REPL: 474 conquest.webapp/eval12393 

Exception copied from cider buffer.

My versions of libraries used are "0.7.0" for all reitit libs.

What could be the reason for this behaviour? How can i fix it?

4
  • I would suggest to first get rid of that exception stacktrace prettifier that you're using and updating the stacktrace in the post with the actual one. Because as it is right now, I cannot even tell what class was not found - was it reitit.ring.Endpoint$reify__4406 or is that just the location where it happened. Commented Sep 10 at 9:57
  • Also, what version of reitit libraries do you have? Commented Sep 10 at 10:01
  • I was running everything from cider. Frankly, i gave no idea what class reify fails to find, seeing as Endpoint is defined with (defrecord ...) with fields only. How should i run it to get raw stacktrace, then? Commented Sep 10 at 12:06
  • No clue about Cider and its settings, but you can try running it via the plain clj or lein, without any extra tools in between. Commented Sep 10 at 13:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.