Andrea Fiore
Andrea Fiore

Reputation: 1638

java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite when running Leiningen

I have just downloaded Leiningen but I cannot manage to run it. After downloading its own Jar archive, the script fails with a java error. By running bash -x lein I can see that it hangs at this line:

+ exec java -Xbootclasspath/a:/home/andrea/.m2/repository/org/clojure/clojure/1.2.1/clojure-1.2.1.jar -client -Dleiningen.original.pwd=/home/andrea/bin -cp /home/andrea/.clojure/clojure.jar:::::test/:src/:resources/:/home/andrea/.lein/self-installs/leiningen-1.6.2-standalone.jar clojure.main -e '(use '\''leiningen.core)(-main)' /dev/null

Which produces:

Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6476)
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)

Interestingly, what fails is not the Java call, but the snippet '(use '\''leiningen.core)(-main)'. Running that line without it fires in fact a working clojure REPL. The leiningen-1.6.2-standalone.jar seem to be in the right path. Any ideas? I am new to both Java and Clojure...

Upvotes: 3

Views: 1133

Answers (2)

michel-slm
michel-slm

Reputation: 9756

Chui Tey's answer points in the right direction. If, however, you don't have a stand-alone Clojure installation, but instead solely use Leiningen to bootstrap your projects, you should instead add the Leiningen standalone JAR to the classpath.

Thus:

export CLASSPATH="$CLASSPATH:$HOME/.lein/self-installs/leiningen-VERSION-standalone.jar"

Upvotes: 1

Chui Tey
Chui Tey

Reputation: 5554

According the the reference [1], you need to add Clojure home to the classpath.

echo "export CLOJURE_HOME=$HOME/Opt/clojure
export CLASSPATH=$CLASSPATH:$CLOJURE_HOME" >> $HOME/.profile

[1] http://myminutes.wordpress.com/2011/12/01/clojure-lein-gives-error-exception-in-thread-main-java-lang-runtimeexception-java-lang-nosuchmethoderror-clojure-lang-keywordlookupsite/

Upvotes: 2

Related Questions