Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lein uberjar fails on simple '-main' usage, but perhaps I don't understand all it's doing?

I've created a simple example using:

%> lein new lein-check

I've only modified the code so that it now has a 'main':

(defproject lein-check "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :main "lein-check.core"
  :dependencies [[org.clojure/clojure "1.4.0"]])

(ns lein-check.core
    (:gen-class))

(defn -main
  "I don't do a whole lot."
  [& args]
  (println "Hello, World!"))

But the first time I run lein uberjar even after a clean I get this:

Compiling lein-check.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:3659)
        at clojure.core$load_one.invoke(core.clj:5228)
        at clojure.core$compile$fn__4895.invoke(core.clj:5426)
        at clojure.core$compile.invoke(core.clj:5425)
        at user$eval7.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:6511)
        at clojure.lang.Compiler.eval(Compiler.java:6501)
        at clojure.lang.Compiler.eval(Compiler.java:6477)
        at clojure.core$eval.invoke(core.clj:2797)
        at clojure.main$eval_opt.invoke(main.clj:297)
        at clojure.main$initialize.invoke(main.clj:316)
        at clojure.main$null_opt.invoke(main.clj:349)
        at clojure.main$main.doInvoke(main.clj:427)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:419)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.Var.applyTo(Var.java:532)
        at clojure.main.main(main.java:37)
Compilation failed: Subprocess failed

Running a follow up uberjar though successfully creates the jars:

Created ....\lein-check-0.1.0-SNAPSHOT.jar
Including lein-check-0.1.0-SNAPSHOT.jar
Including clojure-1.4.0.jar
Created ....\lein-check-0.1.0-SNAPSHOT-standalone.jar

Is uberjar sometimes running the main after a completion? Is it supposed to do that? I'm not quite sure if this is a user error, a lein bug or a clojure bug.

like image 447
lucidquiet Avatar asked Jan 04 '13 17:01

lucidquiet


1 Answers

The problem is in the line

 :main "lein-check.core"

It should be

 :main lein-check.core

You're using a string instead of a symbol.

like image 110
Diego Basch Avatar answered Oct 29 '22 16:10

Diego Basch