Fork me on GitHub
#luminus
<
2021-11-17
>
olaf03:11:26

I'm totally blocked and not able to debug the following error. I stopped the repl and tried to run again but I'm getting this

Caused by: java.lang.ClassCastException: class mount.core.DerefableState cannot be cast to class clojure.lang.IFn (mount.core.DerefableState is in unnamed module of loader clojure.lang.DynamicClassLoader @4fe875be; clojure.lang.IFn is in unnamed module of loader 'app')
        at socn.db.core$eval15854$fn__15855.invoke(core.clj:14)
lein repl inside the project is having the same problem I read that is something related to the db.core/**db** that is required before it's started but I'm not sure where is this happening.
(ns socn.db.core
  (:require
    [cheshire.core :refer [generate-string parse-string]]
    [next.jdbc.date-time]
    [next.jdbc.prepare]
    [next.jdbc.result-set]
    [clojure.tools.logging :as log]
    [conman.core :as conman]
    [socn.config :refer [env]]
    [mount.core :refer [defstate]])
  (:import (org.postgresql.util PGobject)))

(defstate ^:dynamic *db*
  :start (if-let [jdbc-url (env :database-url)]
           (conman/connect! {:jdbc-url jdbc-url})
           (do
             (log/warn "database connection URL was not found, please set :database-url in your config, e.g: dev-config.edn")
             *db*))
  :stop (conman/disconnect! *db*))

JoaquinIglesias11:11:43

Does that happen when starting the server or when trying to start the repl?

JoaquinIglesias11:11:28

What flags have you added when creating the new lein template? Does the error happens when starting the repl or when starting the server? Could we get a glimpse at the full stacktrace?

olaf12:11:23

Reading the errors from lein repl I found the problem. I was testing a function call that I wrote outside a comment macro. My fault 😞 Thanks @iglesiastj for you help anyway!

JoaquinIglesias13:11:49

You are welcome. That one error happens to me a lot too!