6

I have created a very simple Maven project that builds a .war file. Maven version 3.2.3, Java version 1.7.0_67. The pom.xml file is in this gist.

If I run mvn clean install, then the project builds fine. But if I first download all dependencies with mvn dependency:resolve and mvn dependency:resolve-plugins, then run mvn -o install to build offline, I get an error like the following.

[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ docker-restaesy-1 ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-project:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-core:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-settings:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-model:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.2.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:3.0.15 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.2 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.19 is missing, no dependency information available
[WARNING] Error injecting: org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
java.lang.NoClassDefFoundError: Lorg/sonatype/plexus/build/incremental/BuildContext;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2436)
    at java.lang.Class.getDeclaredFields(Class.java:1806)
    at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
    at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
    at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
    at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)
    at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
...
Caused by: java.lang.ClassNotFoundException: org.sonatype.plexus.build.incremental.BuildContext
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.544 s
[INFO] Finished at: 2014-12-09T23:24:57+00:00
[INFO] Final Memory: 9M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project docker-restaesy-1: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources failed: A required class was missing while executing org.apache.maven.plugins:maven-resources-plugin:2.7:resources: Lorg/sonatype/plexus/build/incremental/BuildContext;
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-resources-plugin:2.7
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/2.7/maven-resources-plugin-2.7.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar
[ERROR] urls[2] = file:/root/.m2/repository/org/apache/maven/shared/maven-filtering/1.2/maven-filtering-1.2.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.19/plexus-interpolation-1.19.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

I diff the .m2/repository folder created from the two ways, the one created with dependency plugin is missing many files, most of them related to plexus.

So why doesn't the dependency plugin resolve all the dependencies? Am I doing something wrong here? Thanks

Edit I get the same error with mvn dependency:go-offline

stackoverflower
  • 3,885
  • 10
  • 47
  • 71
  • My suspicion is that some plugins use the dependency plugin to resolve dependencies at run time – stackoverflower Dec 10 '14 at 18:49
  • You have other problems cause the messages `The POM for org.apache.maven:maven-plugin-api:jar:2.2.1 is missing, no dependency information available` show that you haven't downloaded all appropriate files. Which is the root cause here. – khmarbaise Dec 17 '14 at 09:10

1 Answers1

0

I understand this is too late but posting this answer if it help someone. java.lang.ClassNotFoundException: clearly means that jar for org.sonatype.plexus.build.incremental.BuildContext is

  1. not available
  2. available but in wrong path
  3. jar is corrupt

jar responsible for this class is plexus-build-api-0.0.4.jar

check your build output and see which path mvn is looking for this jar. as an example I have below line in my output /Users/akash/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/

In my case jar plexus-build-api-0.0.4.jar was corrupt in this path. I checked with $jar -tbv , it it do not return class names , then its corrupt I downloaded it from link and worked form me. In your case you do not have this path so you will have to re-create project/reinstall plugins.

you can also try to create this path manually, download jars from linklink and see if it works.

akash
  • 1