0

I have compiled an uberjar from a file like:

(defmain HadoopTest (:use 'cascalog.api) (defn bla ("alot of code"))

I run that uberjar on hadoop like:

$ hadoop jar myStandalone.jar clojure.main

and i get a REPL, but nothing from that file is executed. I still have to type (:use 'cascalog.api) and (defn bla) by hand. Why is that the case and how do i fix it?

thanks a lot!

1 Answers1

1

If you supply a class name to hadoop jar <jar file> [<main class>] ... it will call the main method that is contained in that class. Since you are using clojure.main here, a REPL will be spun up (because that's what clojure.main.main() is supposed to do).

So, either use the right class (your AOT-compiled Clojure namespace, I guess), or store that information in your Uberjar (e.g. via Leiningen's :main key in the project file) and leave out the classname, calling only hadoop jar myStandalone.jar.

xsc
  • 5,983
  • 23
  • 30
  • Thank you very much, is it also possible to call main class and use REPL? or only REPL or Main class? – Christian Einstein Oct 29 '13 at 15:17
  • 1
    If you want a REPL with a number of namespaces already loaded, you could actually use the `--eval` parameter: `hadoop jar myStandalone.jar clojure.main --eval "(use 'my.namespace)" --repl` should evaluate `(use 'my.namespace)` before offering a REPL prompt. (Something like `--eval "(require 'my.namespace) (apply my.namespace/-main *command-line-args*)"` would probably work for directly calling a function, although it seems messy and I'd not really recommend it.) – xsc Oct 29 '13 at 15:47