Closed ancaemcken closed 3 years ago
I've figured it out.
I had a nasty extra space after .stop. And I had reversed the lines in the :server/jetty bit (println was the last).
Sorry for the noise :facepalm:
I encountered the same issue, but the root cause is different 😅
During debugging with user
namespace already loaded to the REPL, evaluating state/system
yielded:
{:cheffy/app #object[clojure.lang.AFunction$1 0x4d7be557 "clojure.lang.AFunction$1@4d7be557"],
:server/jetty nil}
The reason for :server/jetty
being null is because my below ig/init-key
implementation returns null instead of the jetty server:
(defmethod ig/init-key :server/jetty
[_ {:keys [handler port]}]
{:pre [(some? handler) (int? port)]}
(run-jetty handler {:port port :join? false})
(println (str "Ya know what? App running at port " port)))
The fix is simple:
(ns chaffy.server
(:require [environ.core :refer [env]]
[integrant.core :as ig]
[reitit.ring :as ring]
[ring.adapter.jetty :refer [run-jetty]])
(:import (org.eclipse.jetty.server Server)))
(defmethod ig/init-key :server/jetty
[_ {:keys [handler port]}]
{:pre [(some? handler) (int? port)]}
(let [^Server server (run-jetty handler {:port port :join? false})]
(println (str "Ya know what? App running at port " port))
server))
Or, just swapping the order of the two last expressions would do the work:
(defmethod ig/init-key :server/jetty
[_ {:keys [handler port]}]
{:pre [(some? handler) (int? port)]}
(println (str "Ya know what? App running at port " port))
(run-jetty handler {:port port, :join? false}))
Hi Jacek,
Noob at Clojure and Java here! I don't know if these two are related, but here goes.
I'm getting the following error in the REPL when trying to eval
(halt)
fromuser.clj
.The IDE is also greying out and striking through the
stop
method with deprecation warnings:java.lang.Thread.stop is marked as deprecated
andjava.lang.ThreadGroup.stop is marked as deprecated
My setup: Fedora 32 64-bit IDEA community (latest) with Cursive. Clojure 1.10.0 JDK adopt-openjdk-15.0.1
I tried googling the stuff and became none the wiser for it.
What am I missing? Any directions for a fix?