Weird error connecting REPL to `lein swank`

28 views
Skip to first unread message

Nick Klauer

unread,
Nov 8, 2011, 3:51:56 PM11/8/11
to clojured...@googlegroups.com
I'm not sure if this is a Leiningen issue or a Counterclockwise one, but whenever I try to run a swank server through Leiningen, as soon as I connect to it from Eclipse, I get this funny output:

 
PS C:\mydocs\Clojure\test> lein swank
Connection opened on localhost port 4005.
exception in read loop
java.lang.NumberFormatException: For input string: "2
"cod"
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at swank.core.protocol$read_swank_message.invoke(protocol.clj:41)
        at swank.core.connection$read_from_connection.invoke(connection.clj:59)
        at swank.core$read_loop.invoke(core.clj:337)
        at swank.swank$connection_serve$fn__1521$fn__1522.invoke(swank.clj:32)
        at clojure.lang.AFn.applyToHelper(AFn.java:159)
        at clojure.lang.AFn.applyTo(AFn.java:151)
        at clojure.core$apply.invoke(core.clj:540)
        at swank.swank$connection_serve$fn__1521.doInvoke(swank.clj:29)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Unknown Source)

I'm running a Windows XP machine with leiningen 1.6.1.1 (I've also tried a recent 1.6.2-SNAPSHOT, same effect).

Any reason what might be the issue?

Laurent PETIT

unread,
Nov 8, 2011, 5:07:24 PM11/8/11
to clojured...@googlegroups.com
lein swank server and CCW's nREPL client are not compatible.

CCW's nREPL client must talk to a nREPL server. You can embed the tools.nrepl jar in your app as a :dev-dependency, trigger the start of the server somehow (more on this on tools.nrepl's github pages), and then connect to it from CCW.

HTH,

-- Laurent

2011/11/8 Nick Klauer <Kla...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "counterclockwise-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/clojuredev-users/-/Np2X6VinDZgJ.
To post to this group, send email to clojured...@googlegroups.com.
To unsubscribe from this group, send email to clojuredev-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojuredev-users?hl=en.

Chas Emerick

unread,
Nov 8, 2011, 6:33:27 PM11/8/11
to clojured...@googlegroups.com
Nick,

If you're just wanting to get a REPL open in Eclipse, right-click on your project's node and choose Run As > Clojure Application.  This will open up a REPL interaction view.

If you have a separate process you're starting elsewhere but would like to connect to from Eclipse, Laurent is right that you need to add nREPL to your project explicitly and start up an nREPL server (an exact analogue of the process needed to embed swank-clojure within your application).

FWIW, I have it in mind to write a lein-nrepl plugin to make it simpler to get an nREPL server running from the command line.

Cheers,

- Chas

Nick Klauer

unread,
Nov 8, 2011, 10:10:38 PM11/8/11
to clojured...@googlegroups.com
This is very good information to know.  I'm new to Clojure and all it's tools, and Eclipse / CCW seems to be my best bet to get things working well in Windows.  

I was able to get this to work now.  I'll back up and try reading some docs, since this is probably something I could/should have caught on the site, correct?

It took me a bit to figure out that i needed to type Ctrl+Enter to get anything to evaluate, but that is minor.

Otherwise, thanks for the help, and apologies for any overly repeated questions.  Excitement gets the best of me sometimes. :)

Nick Klauer

unread,
Nov 9, 2011, 9:53:59 PM11/9/11
to clojured...@googlegroups.com
Are there any instructions for running an nrepl server?  I've been having some weird issues with Eclipse and thought I might try externalizing the REPL to see if that lets me use it.  I've tried to install nrepl to my leiningen project by adding the [org.clojure/tools.nrepl "0.0.5"] dependency, but I'm a little confused how I might start it up.  I've tried:

java -cp "lein classpath" clojure.tools.nrepl.start-server

But whenever I do, I get the error: "Error: Could not find or load main class clojure.tools.nrepl.start-server"  or whatever random class I've tried to pass in.

Any tips?
Reply all
Reply to author
Forward
0 new messages