TreeRex
TreeRex

Reputation: 517

Clojure app built with lein uberjar not launching

I have a small command-line Clojure app that is built with 'lein uberjar'. The result jar file, when started does not call my main function, nor does it give me any kind of stack trace or other indication of an error condition.

% lein version
Leiningen 2.0.0 on Java 1.7.0_10 Java HotSpot(TM) 64-Bit Server VM
% lein uberjar
Compiling spelunker.core
Compiling spelunker.core
Created /Users/temerson/Work/ddp-qa-tool/spelunker/target/spelunker-0.1.0-SNAPSHOT.jar
Including spelunker-0.1.0-SNAPSHOT.jar
Including lucene-core-3.6.2.jar
Including clojure-1.4.0.jar
Created /Users/temerson/Work/ddp-qa-tool/spelunker/target/spelunker-0.1.0-SNAPSHOT-standalone.jar 

% java -jar target/spelunker-0.1.0-SNAPSHOT-standalone.jar
%

It should display a usage message, instead nothing. I've checked the (to me) obvious things: my project file contains

(defproject spelunker "0.1.0-SNAPSHOT"
  :description "Spelunk through Lucene data to find nuggets of useful data."
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.apache.lucene/lucene-core "3.6.2"]]
  :main spelunker.core
  :aot [spelunker.core])

and spelunker/core.clj includes

(ns spelunker.core
  (:import (org.apache.lucene.analysis.standard StandardAnalyzer)
           (org.apache.lucene.document Document Field Field$Store Field$Index)
           (org.apache.lucene.index IndexReader IndexWriter IndexWriter$MaxFieldLength)
           (org.apache.lucene.store NIOFSDirectory RAMDirectory)
           (org.apache.lucene.util Version))
  (:gen-class))

and the main function is defined thusly (for now):

(defn -main [& args]
  (print "DAFUQ?"))

For all intents and purposes this should work: if I create a stub app with leiningen app new it works fine. But not with the above.

I'd feel fine if I at least got some kind of stack trace (i.e., something I could investigate), but the silence is killing me.

Anyone have any ideas?

Many thanks.

Upvotes: 3

Views: 1682

Answers (1)

A. Webb
A. Webb

Reputation: 26446

You did not flush before exit. Change print to println in -main and the newline will auto flush, or otherwise follow your print with an explicit flush.

Upvotes: 2

Related Questions