healthfinch / depstar

A clj-based uberjarrer. See version maintained by Sean for up to date releases.
https://github.com/seancorfield/depstar
104 stars 24 forks source link

Stream closed exception #4

Open danielsz opened 6 years ago

danielsz commented 6 years ago

I'm running the following

clj -A:depstar -m hf.depstar.uberjar myproject.jar

Which results in a Stream closed exception. It seems to be stumbling on data_readers.clj from a dependency, but that's just a guess. Any idea?

{:warning "clashing jar item", :path "about.html"}
{:warning "clashing jar item", :path "deps.cljs"}
{:warning "clashing jar item", :path "deps.cljs"}
{:warning "clashing jar item", :path "javax/transaction/Transaction.class"}
{:warning "clashing jar item", :path "javax/transaction/HeuristicCommitException.class"}
{:warning "clashing jar item", :path "javax/transaction/RollbackException.class"}
{:warning "clashing jar item", :path "javax/transaction/InvalidTransactionException.class"}
{:warning "clashing jar item", :path "javax/transaction/UserTransaction.class"}
{:warning "clashing jar item", :path "javax/transaction/TransactionRequiredException.class"}
{:warning "clashing jar item", :path "javax/transaction/TransactionSynchronizationRegistry.class"}
{:warning "clashing jar item", :path "javax/transaction/NotSupportedException.class"}
{:warning "clashing jar item", :path "javax/transaction/HeuristicRollbackException.class"}
{:warning "clashing jar item", :path "javax/transaction/xa/XAException.class"}
{:warning "clashing jar item", :path "javax/transaction/xa/Xid.class"}
{:warning "clashing jar item", :path "javax/transaction/xa/XAResource.class"}
{:warning "clashing jar item", :path "javax/transaction/TransactionManager.class"}
{:warning "clashing jar item", :path "javax/transaction/Synchronization.class"}
{:warning "clashing jar item", :path "javax/transaction/SystemException.class"}
{:warning "clashing jar item", :path "javax/transaction/HeuristicMixedException.class"}
{:warning "clashing jar item", :path "javax/transaction/TransactionRolledbackException.class"}
{:warning "clashing jar item", :path "javax/transaction/Status.class"}
{:warning "clashing jar item", :path "META-INF/README"}
{:warning "clashing jar item", :path "META-INF/README"}
{:warning "clashing jar item", :path "data_readers.clj"}
Exception in thread "main" java.io.IOException: Stream closed
        at java.base/java.util.zip.ZipInputStream.ensureOpen(ZipInputStream.java:68)
        at java.base/java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:117)
        at java.base/java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:142)
        at java.base/java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:179)
        at hf.depstar.uberjar$consume_jar.invokeStatic(uberjar.clj:90)
        at hf.depstar.uberjar$consume_jar.invoke(uberjar.clj:83)
        at hf.depstar.uberjar$eval195$fn__196.invoke(uberjar.clj:117)
        at clojure.lang.MultiFn.invoke(MultiFn.java:238)
        at hf.depstar.uberjar$copy_source.invokeStatic(uberjar.clj:157)
        at hf.depstar.uberjar$copy_source.invoke(uberjar.clj:155)
        at hf.depstar.uberjar$run$fn__225.invoke(uberjar.clj:193)
        at clojure.core$run_BANG_$fn__8431.invoke(core.clj:7635)
        at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
        at clojure.core$reduce.invokeStatic(core.clj:6747)
        at clojure.core$run_BANG_.invokeStatic(core.clj:7630)
        at clojure.core$run_BANG_.invoke(core.clj:7630)
        at hf.depstar.uberjar$run.invokeStatic(uberjar.clj:193)
        at hf.depstar.uberjar$run.invoke(uberjar.clj:189)
        at hf.depstar.uberjar$_main.invokeStatic(uberjar.clj:199)
        at hf.depstar.uberjar$_main.invoke(uberjar.clj:197)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.lang.Var.applyTo(Var.java:702)
        at clojure.core$apply.invokeStatic(core.clj:657)
        at clojure.main$main_opt.invokeStatic(main.clj:317)
        at clojure.main$main_opt.invoke(main.clj:313)
        at clojure.main$main.invokeStatic(main.clj:424)
        at clojure.main$main.doInvoke(main.clj:387)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:702)
        at clojure.main.main(main.java:37)
danielsz commented 6 years ago

So, it appears to be indeed related to data_readers.clj. I've confirmed it in my fork. https://github.com/danielsz/depstar/commit/abd70e29135984d92dd61ee3d8e0c6d9295e4eaf

Could it be that there is a problem around the multimethod dispatching to the :merge-edn strategy for data_readers.clj?

seancorfield commented 6 years ago

The exception comes from .getNextJarEntry on line 90 in consume-jar https://github.com/healthfinch/depstar/blob/master/src/hf/depstar/uberjar.clj#L90

I've run into this a lot and it always happens at the end of the JAR being consumed and it pretty much always seems to be data_readers.clj in some Clojure JAR.

In my fork, I wrapped the .getNextJarEntry call in (try ... (catch Exception _)) and everything seems to work just fine...

seancorfield commented 6 years ago

See PR #9 (feel free to use my fork @danielsz as I plan to keep it well-maintained, given that we're relying on this heavily at work now).

danielsz commented 6 years ago

Thank you, @seancorfield . That is good to know. Had I known about it at the time I was trying to make things work, I probably wouldn't have written Meyvn, but that's OK, Meyvn turned out quite capable on its own.

seancorfield commented 5 years ago

In case other folks try to use the Healthfinch version and trip over this: the well-maintained fork is here https://github.com/seancorfield/depstar