Skip to content

Instantly share code, notes, and snippets.

@reinhrst
Created March 8, 2012 10:59
Show Gist options
  • Save reinhrst/2000430 to your computer and use it in GitHub Desktop.
Save reinhrst/2000430 to your computer and use it in GitHub Desktop.
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol

When doing lein compile or lein jar, I ran into this error. While at the same time lein run worked fine (at least most of the time...)

#~/foo 11:51:59 > lein jar
Compiling foo.core
Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
at clojure.core$find_ns.invoke(core.clj:3657)
at clojure.core$load_one.invoke(core.clj:5201)
at clojure.core$compile$fn__4615.invoke(core.clj:5397)
at clojure.core$compile.invoke(core.clj:5396)
at user$eval27.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)

After several hours of debugging, I cracked it:

#~/foo 11:53:55 > cat project.clj 
(defproject foo "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :main "foo.core"
  :dependencies [[org.clojure/clojure "1.3.0"]])

Turns out that :main must not be a string (although this works fine in lein run), but a Symbol

#~/foo 11:53:55 > cat project.clj 
(defproject foo "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :main 'foo.core
  :dependencies [[org.clojure/clojure "1.3.0"]])

Hope this will help someone save several hours!

@mackenziestarr
Copy link

thank you for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment