Possible Duplicate:
Clojure error on thread: java.lang.IllegalArgumentException: Key must be integer
This code is so simple, I am confused how it could go wrong. I have:
(defn create-server [port]
(let [ss (new ServerSocket port)]
(start-thread (fn [ss]
(while (not (. ss (isClosed)))
(try (listen-and-respond ss)
(catch SocketException e)))))))
(defn -main [& args]
(println "Server is starting")
(let [port (Integer/parseInt (first args))]
(println "port: " port)
(create-server port)))
I compile this, then uberjar it, then start it on the command line. These lines:
(println "Server is starting")
(println "port: " port)
prints out:
Server is starting port: 3457
On the next line, create-server is called and I get this error:
Exception in thread "Thread-1" clojure.lang.ArityException: Wrong number of args (0) passed to: core$create-server$fn
at clojure.lang.AFn.throwArity(AFn.java:437)
at clojure.lang.AFn.invoke(AFn.java:35)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:680)
Clearly, the line in -main can not be a problem, because I know that "port" has a value of 3457 the line before the first call to create-server. I also notice this error is in Thread-1, so I am thinking that somehow this code recurs in a way that I don't understand.
Any thoughts?