Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.util.zip.ZipException: archive is not a ZIP archive #270

Closed
infsaulo opened this issue Jan 15, 2017 · 10 comments
Closed

java.util.zip.ZipException: archive is not a ZIP archive #270

infsaulo opened this issue Jan 15, 2017 · 10 comments

Comments

@infsaulo
Copy link

infsaulo commented Jan 15, 2017

When I try to invoke ./gradlew clean shadowJar to compile and assemble my jar with all dependencies I'm hitting the error java.util.zip.ZipException: archive is not a ZIP archive as I wrote here.

Is this issue related with my dependencies, or my gradle and/or the shadow plugin versions?

Shadow Version

1.2.4

Gradle Version

3.1

Expected Behavior

Build the jar file with all dependencies when hitting ./gradlew clean shadowJar.

Actual Behavior

Getting the error: java.util.zip.ZipException: archive is not a ZIP archive

Gradle Build Script(s)

Bellow some parts of the my build.gradle script that might be relevant:

buildscript {
repositories {
    maven {
        url "https://plugins.gradle.org/m2/"
    }
}
dependencies {
    classpath "pl.allegro.tech.build:axion-release-plugin:+"
    classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:+"
    classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}

apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'pl.allegro.tech.build.axion-release'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.johnrengelman.shadow'

.
.
.

dependencies {

compile 'org.apache.spark:spark-core_2.10:2.0.0'
compile 'org.apache.spark:spark-mllib_2.10:2.0.0'
compile 'org.apache.bahir:spark-streaming-zeromq_2.10:2.0.0'
compile 'com.typesafe.akka:akka-actor_2.10:+'
compile 'com.typesafe.akka:akka-remote_2.10:+'
compile 'org.apache.hadoop:hadoop-azure:2.7.3'

compile 'org.apache.commons:commons-math3:+'

compile('com.toolbox:spark-documentdb-io:+'){
    exclude module: 'spark-core_2.10'
}

testCompile 'junit:junit:+'
}

jar {
zip64 true
doFirst {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

shadowJar {
append 'reference.conf'
}
@infsaulo infsaulo changed the title Error when running gradle shadowJar java.util.zip.ZipException: archive is not a ZIP archive Jan 15, 2017
@centic9
Copy link

centic9 commented Jul 26, 2017

As I run into similar errors with shadowJar, any hint how you solved this?

@cyph3rcod3r
Copy link

Anyone found solution for this?

@johnrengelman
Copy link
Collaborator

Not sure why the original poster has the 'doFirst' block configuring the shadowJar task. That's not needed. Perhaps it is causing an issue.

@johnrengelman
Copy link
Collaborator

Also if someone posts a full stack trace of the error that would help.

@StefenSharkey
Copy link

@codetojoy
Copy link

codetojoy commented Sep 25, 2017

I get a similar error. The context is for a client and can't be shared. I'm working on trying to reproduce it in a sandbox example. My intuition is that it is related to the size of the deliverable. Any info would be greatly appreciated.

UPDATE: in my case, I had been including an in-house, binary artifact as a jar, when in fact it was another format. This was intentional and worked with a simple Gradle application. However, the Shadow plugin (quite rightly) chokes on it.

@johnrengelman
Copy link
Collaborator

@StefenSharkey why are you setting this? - https://gist.github.com/StefenSharkey/aaf4c82221cfa558060302dfe241d070#file-build-gradle-L47

The error seems to imply that that directory doesn't exist yet.

@zilti
Copy link

zilti commented Oct 18, 2018

This error makes shadowJar completely unusable.

@johnrengelman
Copy link
Collaborator

@zilti - if you’ve read this issue, you would see that it was caused by something in the user’s configuration or an issue with a dependency and shadow is doing exactly what it should do. If the file isn’t a Zip but is claiming to be, there’s nothing else it could do but error.

If you have more information to add or a reproducible example, please open a new issue so it can be investigated.

@alkismavridis
Copy link

Also affected. Not sure if I should ignore this error or if it means something bad about the JAR file I ship to production 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants