ExceptionInInitializerError if jars executed with java -jar

Description

Main-Class set in manifests of target/clojure.jar (or jars in Maven repository) gives impression, that they can be run as standalone JAR-packaged applications.

However running them with

java -jar clojure-${version}.jar

results in

Exception in thread "main" java.lang.ExceptionInInitializerError at clojure.main.<clinit>(main.java:20) Caused by: Syntax error compiling at (clojure/main.clj:1:1). at clojure.lang.Compiler.load(Compiler.java:7647) ... ... 1 more Caused by: java.io.FileNotFoundException: Could not locate clojure/spec/alpha__init.class, clojure/spec/alpha.clj or clojure/spec/alpha.cljc on classpath. at clojure.lang.RT.load(RT.java:466) at clojure.lang.RT.load(RT.java:428)

(It of course works perfectly fine for clojure.jar built in local profile with dependencies shaded.)

Proposed: Remove main class for Clojure jar in Maven, retain it for local jar build (which includes spec jars).

Patch: clj-2459-1.patch

Screened by: Alex Miller - correctly builds normal Clojure without a main class, but continues to build local jar with a main (that one includes the spec deps).

Environment

N/A

Attachments

1
  • 20 Dec 2018, 08:07 PM

Activity

Show:

Alex MillerDecember 11, 2020 at 7:09 PM

Applied for 1.10.2-rc1

Piotr ŻygiełoMarch 22, 2019 at 1:58 PM

Understood, thanks.

Alex MillerMarch 22, 2019 at 1:53 PM

We are trying to keep the changes in 1.10.1 very focused, so it will wait for 1.11.

Piotr ŻygiełoMarch 22, 2019 at 10:52 AM

I see it has assigned 1.11 as fix version, but I also saw preparation for 1.10.1. Could https://clojure.atlassian.net/browse/CLJ-2459#icft=CLJ-2459 be included in 1.10.1 as well?

Alex MillerDecember 21, 2018 at 2:25 PM

Thanks, good call.

Fixed

Details

Assignee

Reporter

Labels

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created December 20, 2018 at 8:04 PM
Updated December 11, 2020 at 7:09 PM
Resolved December 11, 2020 at 7:09 PM