'Maven clean install COMPILATION ERROR cannot access jar, zip END header not found
When building my application on Jenkins using maven I am seeing the following error after running:
mvn clean install -q -U -T 1.5C -DskipTests -Dsvn.info.skip=true
Error:
** [ERROR] COMPILATION ERROR : [ERROR] error reading /apps/jenkins/workspace/some_branch/.m2/com.some_company/any_random.jar; zip file is empty
[ERROR] cannot access com.some_company.some_class cannot access cannot access com.some_company.some_class zip END header not found cannot access jar
I tried excluding the dependency that was causing the issue as it was transitive but now it happens for other dependencies.
The dependencies are stored in nexus.
I have looked at the JDK being used to build the JARS and considered Network issues but nothing explains this.
Clearing Jenkins and the .m2 folder works sometime for one or two builds but I would like to find a better solution.
Any ideas?
Solution 1:[1]
Just delete the file
.m2/com.some_company/any_random.jar
and rerun your goal again. maybe your network or internet connection is slow or your hard disk need check.
Solution 2:[2]
Error reproduction
I've experienced the same error as soon as I've added a global variable at the beginning of a tag in the pom.xml file:
<url>${env.CI_PROJECT_URL}/api/v4/projects/000/packages/maven</url>
Just for a try, I added the a letter at the beginning, even if it doesn't resolve to an existing URL:
<url>a${env.CI_PROJECT_URL}/api/v4/projects/000/packages/maven</url>
And the compilation worked, but the publication could not due to the wrong URL.
Solution
I've solved the error by just interpolating the domain of the server, while I manually wrote the protocol part as https:
<url>https://${env.CI_SERVER_HOST}/api/v4/projects/000/packages/maven</url>
In your case you may need to apply a similar modification in order to solve the issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mohannd |
| Solution 2 | Davide Calarco |
