Question

Following http://www.webnoir.org/ instructions to create a new project - I ran lein uberwar - this generates a single (executable) jar - however it is not able to find the main class as mentioned in the manifest - no class file found.

The app runs run with "lein run".

Is the uberjar meant to be able to run this way (I expect it launches an embedded jetty?)

FYI Jar produced with lein uberjar fails on NoClassDefFoundError is similar - but out of date (this is with a newer version of leiningen where that specific bug is fixed).

Was it helpful?

Solution

The trick is to add gen-class to server.clj

(ns myproject.server ... (:gen-class))

For example: I've just deployed using lein uberjar, and I have the following:

In my project.clj:

:main myproject.server

In my server.clj:

(ns myproject.server
  (:require [noir.server :as server]
    [myproject.views.common]
    [myproject.views.index])
  (:gen-class))

(server/load-views "src/myproject/views/")

(defn -main [& m]
  (let [mode (keyword (or (first m) :dev))
        port (Integer. (get (System/getenv) "PORT" "8080"))]
    (server/start port {:mode mode
                        :ns 'myproject})))
  • require the views at the top
  • gen-class
  • load-views

Now it works fine to java -jar myproject-standalone.jar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top