Search code examples
intellij-ideaclojureleiningen

Running compojure with ring from Intellij IDEA REPL


i have been struggling to start the compojure based application from IntelliJ Idea, i followed instructions provided in this stackoverflow answer

How to use compojure from Intellij

however when i try to load my handler i get *ClassNotFoundException*

(use hello-compojure.handler)
Syntax error (ClassNotFoundException) compiling at (form-init4214569335684752102.clj:1:1).
hello_compojure.handler

below is the handler code

(ns hello-compojure.handler
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))

(defroutes app-routes
  (GET "/" [] "Hello World")
  (GET "/hello" []  "hello second world")
  (route/not-found "Not Found"))

(def app
  (wrap-defaults app-routes site-defaults))

anyone with experience with this type of setup?


Solution

  • turns out i missed ' in my require statement

    Connecting to local nREPL server...
    Clojure 1.10.0
    nREPL server started on port 33629 on host 127.0.0.1 - nrepl://127.0.0.1:33629
    (require 'ring.adapter.jetty)
    => nil
    (require 'hecompojure.handler)
    => nil
    (ring.adapter.jetty/run-jetty hecompojure.handler/app {:port 3004})
    2019-04-05 14:05:34.766:INFO:oejs.Server:jetty-7.6.13.v20130916
    2019-04-05 14:05:34.800:INFO:oejs.AbstractConnector:Started [email protected]:3004