Open csdrane opened 10 years ago
This should be fixed in 0.8.12 (see this PR). Try updating your dependencies to the latest version.
Unfortunately, no, this did not fix the problem.
On Wed, Oct 8, 2014 at 1:08 PM, James Reeves notifications@github.com wrote:
This should be fixed in 0.8.12 (see this PR https://github.com/weavejester/lein-ring/pull/127. Try updating your dependencies to the latest version.
— Reply to this email directly or view it on GitHub https://github.com/weavejester/lein-ring/issues/129#issuecomment-58391699 .
I was able to diagnose the issue. The problem is resolved when I add :main project.core to the :ring map in project.clj.
My guess is that this part of the code (uberjar.clj) is failing for some reason:
(defn default-main-namespace [project]
(let [handler-sym (get-in project [:ring :handler])]
(str (namespace handler-sym) ".main")))
I'm running into this issue, and @csdrane's fix doesn't appear to fix it. Here's my minimal repro:
project.cljs
:
(defproject app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[ring "1.3.2"]]
:main ^:skip-aot app.core
:target-path "target/%s"
:plugins [[lein-ring "0.9.6"]]
:ring {:handler app.core/handler}
:profiles {:uberjar {:aot :all}})
src/app/core.clj
:
(ns app.core)
(defn handler [request] {:status 200
:headers {"Content-Type" "text/html"}
:body "Hello World"})
per the above comment, i also tried with this in project.clj
:
:ring {:handler app.core/handler
:main app.core}
output:
$ lein clean; lein ring uberjar
Compiling app.core
Compiling app.core
Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method.
$ lein -v
Leiningen 2.5.1 on Java 1.8.0_25 Java HotSpot(TM) 64-Bit Server VM
I tried downgrading leiningen, with different but similar results:
$ lein -v
Leiningen 2.4.1 on Java 1.8.0_25 Java HotSpot(TM) 64-Bit Server VM
$ lein clean; lein deps; lein ring uberjar
Compiling app.core
Compiling app.core
Created /Users/jmoon/play/tmp/target/uberjar+uberjar/app-0.1.0-SNAPSHOT.jar
Created /Users/jmoon/play/tmp/target/uberjar+uberjar/app-0.1.0-SNAPSHOT-standalone.jar
$ java -jar target/uberjar+uberjar/app-0.1.0-SNAPSHOT.jar
Error: Could not find or load main class app.core.main
$ java -jar target/uberjar+uberjar/app-0.1.0-SNAPSHOT-standalone.jar
Error: Could not find or load main class app.core.main
my workaround is to just use lein uberjar
with a core.clj
file like this:
(ns app.core
(:gen-class)
(:require [ring.adapter.jetty :as jetty]))
(defn handler [request]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello World"})
(defn -main []
(jetty/run-jetty handler {:port 3000}))
Interesting. It looks like the problem is the :target-path directive -- if I remove that, everything works perfectly. :target-path the way you're using it seems to be legitimate though (it's in the lein sample.project.clj) so I think we're doing something wrong with the target path (the target/uberjar+uberjar+uberjar+.... suggests this too)
yeah, i thought that was a little weird, too, but I'm a clojure and jvm n00b
OK, so part of the problem is that we're merging in the uberjar profile and then passing the project to the uberjar command, but when I fix that, I still see ubjerjar+uberjar going on, and honestly at that point I would love some help from someone who knews leiningen internals better than I do.
Using the following project.clj, I receive the following error when trying to compile with
lein ring uberjar
.I receive no such error and am able to launch a ring server successfully using just
lein uberjar
.