When I run mvn clean install
on my maven project, It is giving me the below error
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ commons ---
[DEBUG] Dependency collection stats {ConflictMarker.analyzeTime=6375, ConflictMarker.markTime=11066, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=2217, ConflictIdSorter.topsortTime=5579, ConflictIdSorter.conflictIdCount=1, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=36123, ConflictResolver.conflictItemCount=1, DefaultDependencyCollector.collectTime=1274402, DefaultDependencyCollector.transformTime=94657}
[DEBUG] org.apache.maven.plugins:maven-jar-plugin:jar:3.2.0
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.1:runtime
[DEBUG] Created new class realm plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
[DEBUG] Importing foreign packages into class realm plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
[DEBUG] Imported: < maven.api
[DEBUG] Populating class realm plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
[DEBUG] Included: org.apache.maven.plugins:maven-jar-plugin:jar:3.2.0
[DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:1.1
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@4b85612c]
[WARNING] Error injecting: org.apache.maven.plugins.jar.JarMojo
java.lang.NoClassDefFoundError: Lorg/apache/maven/archiver/MavenArchiveConfiguration;
at java.lang.Class.getDeclaredFields0 (Native Method)
at java.lang.Class.privateGetDeclaredFields (Class.java:3061)
at java.lang.Class.getDeclaredFields (Class.java:2248)
at com.google.inject.spi.InjectionPoint.getDeclaredFields (InjectionPoint.java:760)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:670)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:182)
at com.google.inject.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:661)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:617)
at com.google.inject.internal.InjectorImpl.initializeJitBinding (InjectorImpl.java:603)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding (InjectorImpl.java:932)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive (InjectorImpl.java:852)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding (InjectorImpl.java:291)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow (InjectorImpl.java:222)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow (InjectorImpl.java:1040)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1071)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1034)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:66)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:127)
at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:61)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:47)
at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050)
at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue (LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:520)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:124)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.ClassNotFoundException: org.apache.maven.archiver.MavenArchiveConfiguration
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass (SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass (ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass (ClassRealm.java:239)
at java.lang.Class.getDeclaredFields0 (Native Method)
at java.lang.Class.privateGetDeclaredFields (Class.java:3061)
at java.lang.Class.getDeclaredFields (Class.java:2248)
at com.google.inject.spi.InjectionPoint.getDeclaredFields (InjectionPoint.java:760)
at com.google.inject.spi.InjectionPoint.getInjectionPoints (InjectionPoint.java:670)
at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields (InjectionPoint.java:378)
at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies (ConstructorBindingImpl.java:182)
at com.google.inject.internal.InjectorImpl.getInternalDependencies (InjectorImpl.java:661)
at com.google.inject.internal.InjectorImpl.cleanup (InjectorImpl.java:617)
at com.google.inject.internal.InjectorImpl.initializeJitBinding (InjectorImpl.java:603)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding (InjectorImpl.java:932)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive (InjectorImpl.java:852)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding (InjectorImpl.java:291)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow (InjectorImpl.java:222)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow (InjectorImpl.java:1040)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1071)
at com.google.inject.internal.InjectorImpl.getProvider (InjectorImpl.java:1034)
at com.google.inject.internal.InjectorImpl.getInstance (InjectorImpl.java:1086)
at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:66)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:127)
at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:61)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:47)
at com.google.inject.internal.InjectorImpl$1.get (InjectorImpl.java:1050)
at org.eclipse.sisu.inject.Guice4$1.get (Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue (LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue (LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup (DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:520)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:124)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.532 s
[INFO] Finished at: 2022-08-11T16:02:56 05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar (default-jar) on project commons: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar failed: A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar: Lorg/apache/maven/archiver/MavenArchiveConfiguration;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/abdul/.m2/repository/org/apache/maven/plugins/maven-jar-plugin/3.2.0/maven-jar-plugin-3.2.0.jar
[ERROR] urls[1] = file:/Users/abdul/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : org.apache.maven.archiver.MavenArchiveConfiguration
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar (default-jar) on project commons: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar failed: A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar: Lorg/apache/maven/archiver/MavenArchiveConfiguration;
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/Users/abdul/.m2/repository/org/apache/maven/plugins/maven-jar-plugin/3.2.0/maven-jar-plugin-3.2.0.jar
urls[1] = file:/Users/abdul/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
-----------------------------------------------------
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar failed: A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar: Lorg/apache/maven/archiver/MavenArchiveConfiguration;
-----------------------------------------------------
realm = plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/Users/abdul/.m2/repository/org/apache/maven/plugins/maven-jar-plugin/3.2.0/maven-jar-plugin-3.2.0.jar
urls[1] = file:/Users/abdul/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of foreign imports: 1
import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar (default-jar) on project commons: Execution default-jar of goal org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar failed: A required class was missing while executing org.apache.maven.plugins:maven-jar-plugin:3.2.0:jar: Lorg/apache/maven/archiver/MavenArchiveConfiguration;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-jar-plugin:3.2.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/abdul/.m2/repository/org/apache/maven/plugins/maven-jar-plugin/3.2.0/maven-jar-plugin-3.2.0.jar
[ERROR] urls[1] = file:/Users/abdul/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
My pom.xml
Have
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
// dependencies section here
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
mvn -v
output
Apache Maven 3.8.4
Maven home: /Users/abdul/apache-maven-3.8.4
Java version: 11.0.13, vendor: Oracle Corporation, runtime: /Users/abdul/jdk-11.0.13.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "11.5", arch: "x86_64", family: "mac"
java -version
output
java version "11.0.13" 2021-10-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.13 10-LTS-370)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13 10-LTS-370, mixed mode)
CodePudding user response:
You can run the maven build command with argument -X
to enable debug logging.
Normally the class MavenArchiveConfiguration
is loaded from maven-archiver
, which is a dependency of the maven-jar-plugin
. These dependencies are managed in the plugins' pom file, and loaded by the maven build process from that pom.
When i locally modify the pom file for this plugin (remove all dependencies
) then i can reproduce this error message. This leads me to believe there is something wrong with your downloaded copy.
As a solution you can remove the contents of .m2\repository\org\apache\maven\plugins\
and .m2\repository\org\apache\maven\maven-archiver
and try your build again, then all correct plugin files and dependencies should be downloaded again from maven central.
Then you should find the jar pom files for the plugin dependency in your local .m2 folder: .m2\repository\org\apache\maven\plugins\maven-jar-plugin\3.2.0
and .m2\repository\org\apache\maven\maven-archiver\3.5.0
. You can also look in those folders for the _remote.repositories
file to check for any download issues.
You can also check if you have any custom pluginRepositories
configured that may be providing you with corrupt jar/pom files. You can see your entire pom file by running mvn help:effective-pom
.
Normally that should include the following from the super pom:
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
More extreme measures could be to download a newer version of maven, or clear your entire local .m2
(create a backup if you have important files in there).
Those would be the places to look to resolve this issue.