Debuggers like JSwat and Eclipse can be remotely attached to live Clojure processes via TCP, but you have to tell the JVM to enable remote debugging when you start it. Leiningen does not presently have an (obvious) way to set
java command line flags in
project.clj, but it does pass the
JAVA_OPTS environment variable to the JVM, so you can do:
JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" lein swank # or "lein repl", etc.
to enable remote debugging. Watch the output for the port it allocates, and put that into JSwat/Eclipse/etc.
Leiningen seems to create more than one JVM when it starts up (one for Leiningen itself and one for the application?), so you can’t specify a particular port to use in JAVA_OPTS (which you could normally do with the “
address=9876” option.) If you do, both JVMs will try to use the same TCP port and your program will crash at startup.