Maven : error in opening zip file when running maven
Asked Answered
L

19

99
[ERROR] error: error reading C:\Users\suresh\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar; error in opening zip file
[ERROR] error: error reading C:\Users\suresh\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar; error in opening zip file
[ERROR] error: error reading C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-rt-bindings-http\2.2.1\cxf-rt-bindings-http-2.2.1.jar; error in opening zip file
[ERROR] error: error reading C:\Users\suresh\.m2\repository\org\codehaus\jra\jra\1.0-alpha-4\jra-1.0-alpha-4.jar; error in opening zip file
[ERROR] error: error reading C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-api\2.2.1\cxf-api-2.2.1.jar; error in opening zip file
[ERROR] error: error reading C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-common-utilities\2.2.1\cxf-common-utilities-2.2.1.jar; error in opening zip file
[INFO] 44 errors

How to resolve this error while running mvn clean install?

And I see that, starting from servlet-api, no packages are being created inside the local repository on my disk.

Lund answered 29/9, 2011 at 15:53 Comment(1)
try: mvn -U clean install. The -U parameter forces maven to update.Tannenbaum
M
92

Probably, contents of the JAR files in your local .m2 repository are HTML saying "301 Moved Permanently". It seems that mvn does not handle "301 Moved Permanently" properly as expected. In such a case, download the JAR files manually from somewhere (the central repository, for example) and put them into your .m2 repository.

See also:

asm-3.1.jar; error in opening zip file
http://darutk-oboegaki.blogspot.jp/2012/07/asm-31jar-error-in-opening-zip-file.html

Mashe answered 13/7, 2012 at 8:37 Comment(0)
I
89

This error sometimes occurs. The files becomes corrupt. A quick solution thats works for me, is:

  • Go to your local repository (in general /.m2/) in your case I see that is C:\Users\suresh.m2)
  • Search for the packages that makes conflicts (in general go to repository/org) and delete it
  • Try again to install it

With that you force to get the actual files

good luck with that!

Isodiametric answered 4/1, 2012 at 20:31 Comment(2)
It seems not work,I delete the ./m2/repository folder again and again,but still fail.Radiochemistry
Is there any way to automate your solution ? Deleting the corrupt zip file and continue the maven command automaticallyPierian
Z
40

Try to remove your repository in /.m2/repository/ and then do a mvn clean install to download the files again.

Zebulun answered 31/1, 2014 at 10:14 Comment(3)
Do not require to remove full .m2/repository, you can delete only erroneous file. That worked for me.Despain
Not recommended. In my case, that would mean removing 32GB of files, just to fix one artifact! @Despain suggestion worked okay.Greenfinch
I'm confused as to why this is an issue. I ran into the same thing, followed this advice and fixed it. But how does using a package in one repo affect another like this?Euphemize
P
13

I had the same problem but previous solutions not work for me. The only solution works for me is the following URL.

https://enlightensoft.wordpress.com/2013/01/15/maven-error-reading-error-in-opening-zip-file/

[EDIT]

Here I explain more about it

Suppose you got an error like below

[ERROR] error: error reading C:\Users\user\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar; error in opening zip file

Then you have to follow these steps.

  1. First, delete the existing jar C:\Users\user\.m2\repository\org\jdom\jdom\1.1\jdom-1.1.jar
  2. Then you have to manually download relevant jar from Maven central repository. You can download from this link here
  3. After that, you have to copy that downloaded jar into the previous directory.C:\Users\user\.m2\repository\org\jdom\jdom\1.1\

Then you can build your project using mvn clean install

hope this will help somebody.

Patristic answered 21/11, 2017 at 4:19 Comment(3)
Can you expand on your answer a little? If the link dies, then the answer doesn't help anymore. A summary from the link will do.Disappointment
Thank you very much, I really hate this thingsBelongings
Event though it works, it is only a workaround since you will need to do so on every machine using the dependency that arrives corrupted.Discretion
H
11
  1. go to the .m2/repository and delete the conflicting files
  2. mvn -U clean install
Handmade answered 31/5, 2014 at 21:26 Comment(1)
These exact step worked. I tried #2 first without delete. But it didn't update the repo and while building my app it says error reading the zip file although the jar is in place.Pydna
C
8

This error can occur when your connection gets interrupted during your dependencies are being downloaded. Delete the relevant repository folder and run following command again to download a fresh copy of corrupted file.

mvn clean install 
Colander answered 19/1, 2015 at 4:55 Comment(1)
Thanks a lot ! It works after deleting the repository folderThee
P
7

I just have this error. You can delete the files and run the compiling command again:

$ sudo rm /Users/Chaklader/.m2/repository/org/apache/poi/poi/3.17/poi-3.17.jar
$ sudo rm /Users/Chaklader/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.7.5/jackson-databind-2.7.5.jar
$ sudo rm /Users/Chaklader/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.7.5/jackson-core-2.7.5.jar

Now, run the command for the clean compile:

$ mvn -U clean compile
Pandora answered 28/6, 2020 at 13:34 Comment(0)
A
5

I had a similar problem as well. The fix was a mix of both. I had a problem with asm-3.1 (as mentioned in the blog post linked by Takahiko. That jar was corrupt. I needed to manually get the jar from the maven central repository. Removing it and retrying just got the corrupt jar again. It then still failed on the asm-parent, which was a POM file containing the HTML with a 301. Again, it required manually getting the file myself. You may want to check what settings XML to see if you're set to a different repository, such as a local nexus server.

When the proper way to get the new one fails, manually grab it yourself.

Aliform answered 7/3, 2013 at 15:17 Comment(0)
I
3
  1. I deleted the jar downloaded by maven
  2. manually download the jar from google
  3. place the jar in the local repo in place of deleted jar.

This resolved my problem.

Hope it helps

Irrefrangible answered 8/6, 2018 at 6:55 Comment(0)
T
2
  1. I deleted the affected jar file from Maven external libraries
  2. Then I performed Maven > Reload project which fixed the library by reinstalling

This worked for me without manually downloading a .jar file

Tbilisi answered 23/8, 2022 at 11:4 Comment(0)
O
1

I also encountered the same problem, my problem has been resolved. The solution is:

According to error information being given, to find the corresponding jar in maven repository and deleted. Then executed mvn install command after deleting.

Orts answered 19/5, 2014 at 6:51 Comment(0)
W
1

Accidently I found a simple workaroud to this issue. Running Maven with -X option forces it to try other servers to download source code. Instead of trash HTML inside some jar files there is correct content.

mvn clean install -X > d:\log.txt

And in the log file you find messages like these:

Downloading: https://repository.apache.org/content/groups/public/org/apache/axis2/mex/1.6.1-wso2v2/mex-1.6.1-wso2v2-impl.jar
[DEBUG] Writing resolution tracking file D:\wso2_local_repository\org\apache\axis2\mex\1.6.1-wso2v2\mex-1.6.1-wso2v2-impl.jar.lastUpdated
Downloading: http://maven.wso2.org/nexus/content/groups/wso2-public/org/apache/axis2/mex/1.6.1-wso2v2/mex-1.6.1-wso2v2-impl.jar

You see, Maven switched repository.apache.org to maven.wso2.org when it encountered a download problem. So the following error is now gone:

[ERROR] error: error reading D:\wso2_local_repository\org\apache\axis2\mex\1.6.1-wso2v2\mex-1.6.1-wso2v2-impl.jar; error in opening zip file
Warga answered 29/7, 2014 at 10:2 Comment(0)
C
1

This issue is a pain in my a$$, I have this issue in my Mac, if I run

mvn clean install | grep "error reading"
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/commons-net/commons-net/3.3/commons-net-3.3.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/commons/commons-lang3/3.0/commons-lang3-3.0.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.54/bcprov-jdk15on-1.54.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/javax/mail/mail/1.4/mail-1.4.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/pdfbox/pdfbox/2.0.0/pdfbox-2.0.0.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/com/itextpdf/itextpdf/5.5.10/itextpdf-5.5.10.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/com/aspose/aspose-pdf/11.5.0/aspose-pdf-11.5.0.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/commons-net/commons-net/3.3/commons-net-3.3.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/commons/commons-lang3/3.0/commons-lang3-3.0.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.54/bcprov-jdk15on-1.54.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/javax/mail/mail/1.4/mail-1.4.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/apache/pdfbox/pdfbox/2.0.0/pdfbox-2.0.0.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/com/itextpdf/itextpdf/5.5.10/itextpdf-5.5.10.jar; error in opening zip file
[ERROR] error reading /Users/ducnguyen/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar; error in opening zip file

Removing all corrupted libs is the only solution

So I want to remove all of them at once.

mvn clean install | grep "error reading" | awk '{print "rm " $4 | "/bin/sh"  }'

The command needs AWK to take libPath string from column $4

Then rerun

mvn clean install
Coatbridge answered 20/2, 2019 at 3:28 Comment(2)
pdfbox 2.0.0 is several years old and has security risks the current version is 2.0.13. And having "rm -rf" in a script is risky too.Mathian
Thank @TilmanHausherr, I updated by remove ` -rf ` , Yes, I updated my repos to use pdfbox 2.0.13Coatbridge
U
1

I got a different issue

/.m2/repository/io/netty/netty-common/4.1.63.Final/netty-common-4.1.63.Final.jar: zip file is empty

after deleting the file from m2 and re running the project the issue was resolved.

Unclothe answered 8/5, 2023 at 9:53 Comment(0)
M
0

For me I should change the .m2 repo in the settings.xml file with another one because in Mac maven can't create a folder that start with point(.)

to solve that, open your maven/version/conf/settings.xml and specify the location of your repo folder like this :

<localRepository>../repo</localRepository>

don't forget to change it also in your IDE, in eclipse go to : Windows > Preferences > Maven > User Settings > Global Settings, and navigate to your settings.xml.

clean install your project.

hope this will help you.

Mccafferty answered 25/10, 2017 at 20:36 Comment(0)
M
0

This error occurs because of some file corruption. But we don't need to delete whole .m2 folder. Instead find which jar files get corrupted by looking at the error message in the console. And delete only the folders which contains those jar files.

Like in the question :

  1. C:\Users\suresh\.m2\repository\org\jdom\jdom\
  2. C:\Users\suresh\.m2\repository\javax\servlet\servlet-api\
  3. C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-rt-bindings-http
  4. C:\Users\suresh\.m2\repository\org\codehaus\jra\jra
  5. C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-api
  6. C:\Users\suresh\.m2\repository\org\apache\cxf\cxf-common-utilities

Delete these folders. Then run.

mvn clean install -U

Mokas answered 7/2, 2019 at 4:34 Comment(0)
M
0

Deleting the entire local m2 repo may not be advisable. As in my case I have hundreds and hundreds of jars in my local, I don't want to re-download them all just for one jar. Most of the above answers didn't work for me, here is what I did.

STEP:1: Ensure if you are downloading from the correct Maven repo in you settings.xml. In my case it was referring to http://central.maven.org/maven2/ as https://repo1.maven.org/maven2/. So it was getting corrupted or going otherwise?

STEP:2: Delete the folder containing the artifact and other details in your local machine.This will force it download it again upon next build

STEP:3: mvn clean install :).

Hope it helps.

Magnitogorsk answered 16/9, 2019 at 14:52 Comment(0)
T
0

I downloaded the jar file manually and replace the one in my local directory and it worked

True answered 2/2, 2020 at 13:24 Comment(0)
R
0

You could also check if the required certificates are installed to make sure that it allows the dependencies to be downloaded.

Rhyolite answered 2/11, 2020 at 6:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.