运行 Leiningen 时出现 java.lang.NoSuchMethodError:clojure.lang.KeywordLookupSite
我刚刚下载了 Leiningen,但无法运行它。下载自己的 Jar 存档后,脚本失败并出现 java 错误。通过运行 bash -x lein ,我可以看到它挂在这一行:
+ 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
生成:
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)
有趣的是,失败的不是 Java 调用,而是代码片段 '(use '\''leiningen .core)(-main)'
。在没有它的情况下运行该行实际上会触发一个工作的 clojure REPL。 leiningen-1.6.2-standalone.jar 似乎位于正确的路径中。有什么想法吗?我对 Java 和 Clojure 都很陌生......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据参考文献[1],您需要将Clojure home添加到类路径中。
[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/
According the the reference [1], you need to add Clojure home to the classpath.
[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/
Chui Tey 的回答指出了正确的方向。但是,如果您没有独立的 Clojure 安装,而是仅使用 Leiningen 来引导您的项目,则应该将 Leiningen 独立 JAR 添加到类路径中。
因此:
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: