Fork me on GitHub
#cider
<
2022-04-07
>
fadrian00:04:39

I'm getting a cider exception in Calva when I try to bring up a REPL in VSCode running under Windows. Needless to say, I'm trying to figure out what's going wrong and why. I'll add details (as they're a bit long) in the thread.

fadrian00:04:35

My project is held on my system in the folder c:\Users\fadrian\Projects\motive-cql-builder\mercator-server. It is a deps.edn project. This is the deps.edn file:

{:paths
 ["src" "resources\\jars\\apelon\\dtscore-4.6.1-838.jar"]

 :deps
 {org.clojure/clojure {:mvn/version "1.10.3"}
  compojure/compojure {:mvn/version "1.6.2"}
  http-kit/http-kit {:mvn/version "2.5.3"}
  ring/ring-json {:mvn/version "0.5.1"}
  ring-cors/ring-cors {:mvn/version "0.1.13"}
  org.clojure/data.json {:mvn/version "2.4.0"}
  mercator/mapper {:local/root "../mercator"}
  mercator/expander {:local/root "../mercator"}
  mercator/primitives {:local/root "../mercator"}
  mercator/templates {:local/root "../mercator"}
  cheshire/cheshire {:mvn/version "5.0.2"}}

 :jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
 
  :aliases {;; build an uberjar (application) with AOT compilation by default:
            :dev {}
            
            :uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
                      :exec-fn hf.depstar/uberjar
                      :exec-args {:aot true}}
  ;; build a jar (library):
            :jar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
                  :exec-fn hf.depstar/jar
                  :exec-args {}}}}
Note the use of the .jar file in the :paths directive. This should add this file to the classpath. However, instead, it throws an error in cider:
java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""0.9.0""},cider/cider-nrepl {:mvn/version,""0.27.4""},cider/piggieback {:mvn/version,""0.5.3""}}}" -M:dev -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
nREPL server started on port 64632 on host 127.0.0.1 - 
ERROR: Unhandled REPL handler exception processing message {:op eval, :code *ns*, :id 1}
Syntax error macroexpanding at (track_state.clj:156:8).
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3711)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705)
        at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
        at clojure.lang.Compiler.eval(Compiler.java:7186)
        at clojure.lang.Compiler.load(Compiler.java:7640)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6856.invoke(core.clj:6115)
        at clojure.core$load.invokeStatic(core.clj:6114)
        at clojure.core$load.doInvoke(core.clj:6098)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5897)
        at clojure.core$load_one.invoke(core.clj:5892)
        at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
        at clojure.core$load_lib.invokeStatic(core.clj:5936)
        at clojure.core$load_lib.doInvoke(core.clj:5917)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$load_libs.invokeStatic(core.clj:5974)
        at clojure.core$load_libs.doInvoke(core.clj:5958)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$require.invokeStatic(core.clj:5996)
        at clojure.core$require.doInvoke(core.clj:5996)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at cider.nrepl$handler_future$fn__2307$fn__2308.invoke(nrepl.clj:53)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1977)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1977)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at cider.nrepl$handler_future$fn__2307.invoke(nrepl.clj:52)
        at clojure.lang.Delay.deref(Delay.java:42)
        at clojure.core$deref.invokeStatic(core.clj:2324)
        at clojure.core$deref.invoke(core.clj:2310)
        at cider.nrepl$wrap_tracker$fn__2512.invoke(nrepl.clj:480)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at cider.nrepl$wrap_out$fn__2448.invoke(nrepl.clj:332)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at cider.nrepl.middleware.inspect$eval_reply.invokeStatic(inspect.clj:71)
        at cider.nrepl.middleware.inspect$eval_reply.invoke(inspect.clj:69)
        at cider.nrepl.middleware.inspect$handle_inspect.invokeStatic(inspect.clj:110)
        at cider.nrepl.middleware.inspect$handle_inspect.invoke(inspect.clj:108)
        at clojure.lang.Var.invoke(Var.java:388)
        at cider.nrepl$wrap_inspect$fn__2424.invoke(nrepl.clj:225)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at nrepl.middleware.caught$wrap_caught$fn__1211.invoke(caught.clj:97)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at cider.nrepl$wrap_test$fn__2496.invoke(nrepl.clj:440)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at nrepl.middleware.print$wrap_print$fn__1178.invoke(print.clj:234)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at cider.nrepl$wrap_resource$fn__2472.invoke(nrepl.clj:404)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at nrepl.middleware.session$session$fn__1381.invoke(session.clj:325)
        at nrepl.middleware$wrap_conj_descriptor$fn__942.invoke(middleware.clj:16)
        at nrepl.server$default_handler$fn__1949.invoke(server.clj:141)
        at nrepl.server$handle_STAR_.invokeStatic(server.clj:24)
        at nrepl.server$handle_STAR_.invoke(server.clj:21)
        at nrepl.server$handle$fn__1917.invoke(server.clj:41)
        at clojure.core$binding_conveyor_fn$fn__5772.invoke(core.clj:2034)
        at clojure.lang.AFn.call(AFn.java:18)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.file.NoSuchFileException: c:\Users\fadrian\Projects\motive-cql-builder\mercator-server\resources\jars\apelon\dtscore-4.6.1-838.jar
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
        at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
        at java.base/sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:199)
        at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1264)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:347)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:318)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:284)
        at cider.nrepl.middleware.track_state$fn__3870.invokeStatic(track_state.clj:155)
        at cider.nrepl.middleware.track_state$fn__3870.invoke(track_state.clj:155)
        at clojure.core$map$fn__5884.invoke(core.clj:2759)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        at clojure.lang.LazySeq.seq(LazySeq.java:51)
        at clojure.lang.RT.seq(RT.java:535)
        at clojure.core$seq__5419.invokeStatic(core.clj:139)
        at clojure.core$map$fn__5884.invoke(core.clj:2750)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        at clojure.lang.LazySeq.seq(LazySeq.java:51)
        at clojure.lang.RT.seq(RT.java:535)
        at clojure.core$seq__5419.invokeStatic(core.clj:139)
        at clojure.core$apply.invokeStatic(core.clj:662)
        at clojure.core$mapcat.invokeStatic(core.clj:2787)
        at clojure.core$mapcat.doInvoke(core.clj:2787)
        at clojure.lang.RestFn.applyTo(RestFn.java:139)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3706)
        ... 68 more
It seems to be saying that it can't find the referenced .jar file. But the jarfile is there. Any ideas why Cider is throwing this error and how I can work around it?

dpsutton00:04:23

i've followed along in that other thread. I'd urge you to get this working without any tooling and then try to get tooling to work

fadrian01:04:19

After adding a few more quotes around the version numbers, I was able to get theREPL to come up:

PS C:\Users\fadrian\Projects\motive-cql-builder\mercator-server> java -jar ".calva\deps.clj.jar" -Sdeps "{:deps {nrepl/nrepl {:mvn/version,""""0.9.0""""},cider/cider-nrepl {:mvn/version,""""0.27.4""""},cider/piggieback {:mvn/version,""""0.5.3""""}}}" -M:dev -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
nREPL server started on port 65139 on host 127.0.0.1 - 
So it looks like the nrepl starts, but dies when it tries to process the ns declaration in the mercator-server\core.cljs file:
(ns mercator-server.core
  (:gen-class)
  (:require [compojure.core :refer [defroutes GET POST]]
            [mercator.expander :refer [ednize-json-keywords]]
            [mercator.mapper :refer [translate json-template-sets]]
            [org.httpkit.server :refer [run-server]]
            [ring.middleware.cors :refer [wrap-cors]]
            [ring.middleware.json :refer [wrap-json-body wrap-json-response]])
  
  (:import  [com.apelon.dts.client ServerConnectionEJB]
            [java.util Base64]))
When I feed this declaration into the clj REPL, it gives the error:
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:445).
com.apelon.dts.client.ServerConnectionEJB.
The only change I've made to this declaration is the addition of the [com.apelon.dts.client ServerConnectionEJB] import. I've checked the .jar file referenced in the path attribute in the deps.edn file and there is a ServerConnectionEJB.class file in the folder /com/apelon/dts/client in the .jar file. That's the confusing part - everything seems to be in the right place, but the class still isn't being found.

pez09:04:09

To remove the quoting as a source of error, try use just the clj command. It should give you a prompt. Then load that file from that prompt and see what you get.

fadrian12:04:54

I did that. The latest message says what I get when I do that.

fadrian12:04:51

Basically, it says the class is not found, even though it's in the .jar file in the correct place.

fadrian12:04:59

I've got the jarfile appearing in the classpath with a full direct path to the file (i.e., the classpath contains C:\Users\fadrian\Projects\motive-cql-builder\mercator-server\resources\jars\apelon\dtscore-4.6.1-838.jar). The .class file I'm importing is in the .jar file in the right place in the folder hierarchy. So I'm still wondering why the class is not found.

fadrian09:04:55

I finally found the problem. I thought I had placed the resources folder under the mercator-server folder, but it was really under the mercator-server/src/mercator-server folder. I fixed that and the planets re-aligned. In any case, I learned a lot more about (a) figuring out clojure error messages and (b) deps.edn.

metal 1
pez10:04:16

Awesome. Thanks for the update!

Benjamin15:04:47

how to prevent accidentally freezing emacs when printing out some huge (string) when calling cider-eval? I have a coworker that says it happened to him and I don't really have a good answer

César Olea16:04:00

I use (setq cider-repl-buffer-size-limit 100000) to limit the size of the repl buffer and avoid slowing Emacs to a crawl.

👍 1
macrobartfast19:04:00

I just posted a short novel in #clojure asking if anyone would be willing to actually look at my (non) workflow via screenshare… mentioning here as I’m an uncured Emacs/Cider addict.

macrobartfast19:04:36

Open to other suggestions for moving things along, too, of course.

Ian Fernandez21:04:23

How cider via tramp, works?

Ian Fernandez21:04:30

need to tune more configs for it?