Compilation failure: error reading JAR file in ~/.m2/repository; invalid CEN header (bad signature)
Asked Answered
P

3

31

I'm migrating our Java EE project to use Maven instead of Ant.

For the following dependency

    <dependency>
      <groupId>javolution</groupId>
      <artifactId>javolution</artifactId>
      <version>5.4.2</version>
    </dependency>

I get the following error when trying to compile

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:compile (default-compile) on project JAdaptiv: Compilation failure
[ERROR] error: error reading C:\Users\User.IVSTEL1\.m2\repository\javolution\
javolution\5.4.2\javolution-5.4.2.jar; invalid CEN header (bad signature)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on
 project JAdaptiv: Compilation failure
error: error reading C:\Users\User.IVSTEL1\.m2\repository\javolution\javoluti
on\5.4.2\javolution-5.4.2.jar; invalid CEN header (bad signature)

        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation fail
ure
error: error reading C:\Users\Croydon.IVSTEL1\.m2\repository\javolution\javoluti
on\5.4.2\javolution-5.4.2.jar; invalid CEN header (bad signature)

        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompiler
Mojo.java:656)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        ... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
Perloff answered 27/3, 2011 at 23:38 Comment(1)
check this answer #32091421Courser
A
56

This means that javolution-5.4.2 jar in your local repository is corrupt. I checked the maven repo for the 5.4.2 version on this link. You can manually copy the jar from there to your local repository to see if that helps.

You can also try the following steps:-

  1. Delete the jar from your local repository C:\Users\User.IVSTEL1\.m2\repository\javolution\ javolution\5.4.2\javolution-5.4.2.jar. Then maven will download it again for you.
  2. If the 5.4.2 version still has some issues after re-download then try the following version.

    <dependency> <groupId>javolution</groupId> <artifactId>javolution</artifactId> <version>5.5.1</version> </dependency>

Agglomeration answered 27/3, 2011 at 23:46 Comment(3)
That would work too. In the meantime, I ended up setting up a maven repository manager which managed to fetch the proper file.Perloff
Yes if have the capability to host nexus or artifactory like repo manager then that's the ideal solution.Agglomeration
It was sufficient for me to just delete the offending files from my local .m2/repository folder, and re-run the Maven build to download them again. Probably, there was either a network glitch downloading the files, or (more likely) the original publisher accidentally uploaded a corrupt file and then corrected their mistake soon after. Thanks!Salesgirl
B
1

Faced the same issue while deploying the war on Apache Tomcat 10 + JDK 1.8 (same war worked fine with Tomcat 9+ JDK 1.8), could resolve the issue by changing JDK version to 17 (tomcat 10+ JDK 17)

Blavatsky answered 1/2, 2023 at 4:10 Comment(0)
S
0

Steps that I had followed to resolved this issue:

STEP 1 : Deleted the jar from .m2->repository folder

STEP 2 : Deleted maven dependencies from Java Build Path->Libraries

STEP 3 : Right click on Project->Maven->Update Project

Stereochemistry answered 18/4, 2021 at 12:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.