Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lein ring uberjar -- java.lang.NoClassDefFoundError: clojure/lang/Var

Not certain why when I lein with-profile +live ring uberjar and then java -jar my uberjar, I get this exception: java.lang.NoClassDefFoundError: clojure/lang/Var.

project.clj:

(defproject gn-preview-api "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.9.0"]]
  :main gn-preview-api.www.app
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}
             :staging {:aot :all}
             :live    {:aot :all}
             :dev     {:plugins      [[lein-ring "0.9.7"]]
                       :dependencies [[javax.servlet/servlet-api "2.5"]]}})

Any ideas?

like image 534
Micah Avatar asked Jan 03 '23 00:01

Micah


1 Answers

Leiningen produces two .jar files when you run lein uberjar. The one whose filename ends in ...-standalone.jar is the actual uberjar, which contains Clojure (core). The standalone file can be run simply with java -jar my_uberjar.jar. If you run the other (non-uber jar), then Clojure needs to be available in the classpath.

You can view which dependencies are included with each jar file with jar tf my_uberjar.jar. The uberjar should contain clojure/core/..., clojure/lang/..., etc.

like image 188
Toni Vanhala Avatar answered Feb 23 '23 16:02

Toni Vanhala