Maven : error in opening zip file when running maven

后端 未结 17 2181
-上瘾入骨i
-上瘾入骨i 2020-11-29 03:28
[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         


        
相关标签:
17条回答
  • 2020-11-29 03:56

    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
    
    0 讨论(0)
  • 2020-11-29 03:58

    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

    0 讨论(0)
  • 2020-11-29 04:02

    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
    
    0 讨论(0)
  • 2020-11-29 04:03

    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.

    0 讨论(0)
  • 2020-11-29 04:04

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

    0 讨论(0)
提交回复
热议问题