I have a project setup at the moment that works like a charm when I use lein run
.
The minimal case that causes the problem is the following. I have two files, shown below. The core.clj
file is supposed to throw an error and then stop. The error is simply an error that extends the standard Error
of Java. However, when I open up this file in emacs and open up cider I can't get it to compile properly.
core.clj
(ns meta-clojure.core
(:import (org.jsoup Jsoup)
(java.lang String)
(meta_clojure.stm RetryEx)))
(defn -main
[& args]
(println "Throwing exception now..")
(throw (RetryEx. "this is broken"))
(println "End of main")
nil)
RetryEx.clj
(ns meta-clojure.stm.RetryEx
(:gen-class :extends java.lang.Error))
Now, as I said, when I run the lein run
command it executes just fine. However, in emacs I get the following stack trace:
clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: meta_clojure.stm.RetryEx, compiling:(/home/christophe/bitbucket/meta-clojure/src/meta_clojure/core.clj:1:1)
Compiler.java:7142 clojure.lang.Compiler.load
NO_SOURCE_FILE:1 user/eval931
Compiler.java:6703 clojure.lang.Compiler.eval
Compiler.java:6666 clojure.lang.Compiler.eval
core.clj:2927 clojure.core/eval
main.clj:239 clojure.main/repl[fn]
main.clj:239 clojure.main/repl[fn]
main.clj:257 clojure.main/repl[fn]
main.clj:257 clojure.main/repl
RestFn.java:1523 clojure.lang.RestFn.invoke
interruptible_eval.clj:67 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:152 clojure.lang.AFn.applyToHelper
AFn.java:144 clojure.lang.AFn.applyTo
core.clj:624 clojure.core/apply
core.clj:1862 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:51 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:183 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
interruptible_eval.clj:152 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:22 clojure.lang.AFn.run
ThreadPoolExecutor.java:1145 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:615 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:745 java.lang.Thread.run
Caused by: java.lang.ClassNotFoundException: meta_clojure.stm.RetryEx
URLClassLoader.java:366 java.net.URLClassLoader$1.run
URLClassLoader.java:355 java.net.URLClassLoader$1.run
(Unknown Source) java.security.AccessController.doPrivileged
URLClassLoader.java:354 java.net.URLClassLoader.findClass
DynamicClassLoader.java:61 clojure.lang.DynamicClassLoader.findClass
ClassLoader.java:425 java.lang.ClassLoader.loadClass
ClassLoader.java:358 java.lang.ClassLoader.loadClass
(Unknown Source) java.lang.Class.forName0
Class.java:191 java.lang.Class.forName
core.clj:1 meta-clojure.core/eval935[fn]
core.clj:1 meta-clojure.core/eval935
Compiler.java:6703 clojure.lang.Compiler.eval
Compiler.java:6692 clojure.lang.Compiler.eval
Compiler.java:7130 clojure.lang.Compiler.load
Could anyone help me out please? I think I need to tell Cider/Emacs to compile ahead of time or something. Perhaps leiningen compiles to different directories than emacs?