Search code examples
eclipseeclipse-pluginm2e

org.eclipse.m2e.core plugin hitting NullPointerException in Eclipse


Imported a maven project in Eclipse Oxygen and am hitting this issue with org.eclipse.m2e.core plugin when building the project. m2e version is 1.8.3, anybody know why this happens? I have seen similiar issues in bug reports from way back but they were marked as fixed from version 1.1 onwards.

java.lang.NullPointerException
at org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata.getAction(PluginExecutionMetadata.java:144)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.isConfigurator(LifecycleMappingFactory.java:718)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata0(LifecycleMappingFactory.java:602)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(LifecycleMappingFactory.java:535)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(LifecycleMappingFactory.java:249)
at org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory.calculateLifecycleMapping(LifecycleMappingFactory.java:181)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.setupLifecycleMapping(ProjectRegistryManager.java:594)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:513)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:492)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:496)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:351)
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:298)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.getProjectFacade(MavenBuilder.java:154)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:89)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)

Furthermore if you actually go and try to check out the code here:

https://github.com/eclipse/m2e-core/tree/m2e-1.8.x/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping

this package doesn't even seem to exist? WTH is going on here? Has this project been forked to hell and I'm looking in the wrong place? Should I just pack up and start using IntelliJ, seems like m2e has become unmanageable in Eclipse. The lifecyclemapping is defined as such in a parent

  <pluginManagement>
    <plugin>
      <groupId>org.eclipse.m2e</groupId>
      <artifactId>lifecycle-mapping</artifactId>
      <version>1.0.0</version>
      <configuration>
        <lifecycleMappingMetadata>
          <pluginExecutions>
            <pluginExecution>
              <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <versionRange>[2.10,)</versionRange>
                <goals>
                  <goal>unpack-dependencies</goal>
                </goals>
              </pluginExecutionFilter>
            </pluginExecution>
          </pluginExecutions>
        </lifecycleMappingMetadata>
      </configuration>
    </plugin>
  </pluginManagement>

Solution

  • PluginExecutionMetadata is generated from lifecycle-mapping-metadata-model.xml using modello

    The line in the generated code where the NPE happens is

    org.codehaus.plexus.util.xml.Xpp3Dom actionDom = ((org.codehaus.plexus.util.xml.Xpp3Dom) getActionDom()).getChild(0);
    

    This points to the answer: In your xml snippet, the required <action> tag is missing, e.g. like:

                 </pluginExecutionFilter>
                 <action>
                   <ignore/>
                 </action>
               </pluginExecution>