3

After upgrading Leiningen (from v1.6 to v1.7) with lein upgrade command lein swank stopped working with error message:

Exception in thread "main" java.lang.NoClassDefFoundError:  
Caused by: java.lang.ClassNotFoundException:  
[...] 
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class:  .  Program will exit.

Since I tried it from command line, I believe Emacs configuration doesn't matter in this case. So I tried to re-install Leiningen completely. What I've done (using suggestions from here and error messages):

rm -R ~/.m2
# rm ~/.lein/plugins/*  
lein self-install

(I used second line on second reinstallation only, so it is here for the sake of completeness)

Then I created new project and installed lein-swank plugin, since, as far as I understand, it is recommended way at the moment:

lein new test-project
lein plugin install swank-clojure 1.4.0  # I tried earlier version (1.3.2) too

And finally started lein swank with:

cd test-project
lein swank

But got same error as before.

So my questions are:

  1. How to fix this problem?
  2. Do I reinstall Leiningen correctly or some steps are missing?

UPD. Here's project.clj generated with new project:

(defproject test-project "1.0.0-SNAPSHOT"
   :description "FIXME: write description"
   :dependencies [[org.clojure/clojure "1.3.0"]])
Community
  • 1
  • 1
ffriend
  • 27,562
  • 13
  • 91
  • 132
  • Doesn't the error message say what class was not found? Could you please add that to your post. Also, can you please post your `project.clj` file. – liwp Feb 23 '12 at 20:36
  • @liwp: Nope, the error message was just as in a snippet - no class, just space and the dot. `project.clj` was generated by Leiningen and had no modifications. Completely fresh project. Note that from that time I moved to another laptop and there fresh Leinigen installation worked perfectly. – ffriend Feb 23 '12 at 20:51
  • I'd still like to see whether your `project.clj` specifies Clojure 1.2.1 or 1.3.0. – liwp Feb 23 '12 at 20:55
  • @liwp: it is 1.3.0. See my update for full `project.clj` (if that still makes sense). – ffriend Feb 23 '12 at 21:21

1 Answers1

1

Does the swank-clojure troubleshooting page help:

Troubleshooting

Currently having multiple versions of swank-clojure on the classpath can cause issues when running lein swank or lein jack-in. It's recommended to not put swank-clojure in your :dev-dependencies but run lein plugin install to have it installed globally for all projects instead. This also means that people hacking on your project won't have to pull it in if they are not Emacs users.

It's also possible for some packages to pull in old versions of swank-clojure transitively, so check the lib/ directory if you are having issues. In particular, Incanter is known to exhibit this problem. Judicious use of :exclusions make it work:

:dependencies [[incanter "1.2.3" :exclusions [swank-clojure]]]

Since swank-clojure 1.3.4, having versions of clj-stacktrace older than 0.2.1 in your project or user-level plugins will cause Unable to resolve symbol: pst-elem-str errors. Keep in mind that user-level plugins in ~/.lein/plugins are uberjars in Leiningen 1.x, so it's possible that one of your plugins (such as lein-difftest before version 1.3.7) contains an old clj-stacktrace even if it doesn't have its own file there. Specifying a newer version should be enough if you're having trouble:

:dependencies [[clj-stacktrace "0.2.4"]]
liwp
  • 6,746
  • 1
  • 27
  • 39
  • Thanks for the answer, but as I already mentioned I reinstalled Leinigen and had created completely new project. Thus these suggestions are not applicable (unless there is some dependency of Leiningen left that I haven't noticed). Anyway, upvote for relevant answer. – ffriend Feb 23 '12 at 20:55
  • I remember having to add `clj-stacktrace` as a dependency at some point in the recent past to get things to work, but that doesn't seem to be necessary any more with Leiningen 1.7.0 and swank-clojure 1.4.0. Sorry I can't be of more help. I'd suggest deleting everything like you did before, including the `lein` script, and starting from scratch. – liwp Feb 23 '12 at 21:34