Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-5349

NullPointerException if missing id in org.apache.maven.lifecycle.Lifecycle

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.4
    • Fix Version/s: 3.2.3
    • Component/s: Plugins and Lifecycle
    • Labels:
      None
    • Environment:
      Ubuntu Precise, Maven 3.0.4

      Description

      I've been working with custom lifecycles, and accidentally left the "id" out of one of them. You can see it in this example where I commented out the key line (everything works fine if this line is uncommented):

      <component-set>
        <components>
          <component>
            <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
            <role-hint>phase-test</role-hint>
            <implementation>
              org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
            </implementation>
          </component>
          <component>
            <role>org.apache.maven.lifecycle.Lifecycle</role>
            <role-hint>phase-test</role-hint>
            <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
            <configuration>
      <!--         <id>phase-test</id>  -->
               <phases>
                  <phase>tp-pre-new-phase</phase>
                  <phase>tp-new-phase</phase>
                  <phase>tp-post-new-phase</phase>
               </phases>
               <default-phases>
                  <tp-new-phase>org.riedl:phase-test-maven-plugin:greet</tp-new-phase>
               </default-phases>
            </configuration>
          </component>
        </components>
      </component-set>
      ~                           
      

      Here's most of the stack trace:

      (macro: ~/Src/lenskit-projects/tryout-phase-test-plugin) mvn tp-post-new-phase
      [INFO] Scanning for projects...
      [ERROR] Internal error: java.lang.NullPointerException -> [Help 1]
      org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
              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(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
              at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
              at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
              at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
      Caused by: java.lang.NullPointerException
              at java.lang.String.compareTo(String.java:1167)
              at org.apache.maven.lifecycle.internal.DefaultLifecyclePluginAnalyzer$1.compare(DefaultLifecyclePluginAnalyzer.java:144)
              at org.apache.maven.lifecycle.internal.DefaultLifecyclePluginAnalyzer$1.compare(DefaultLifecyclePluginAnalyzer.java:140)
              at java.util.Arrays.mergeSort(Arrays.java:1270)
              at java.util.Arrays.sort(Arrays.java:1210)
              at java.util.Collections.sort(Collections.java:159)
              at org.apache.maven.lifecycle.internal.DefaultLifecyclePluginAnalyzer.getOrderedLifecycles(DefaultLifecyclePluginAnalyzer.java:139)
              at org.apache.maven.lifecycle.internal.DefaultLifecyclePluginAnalyzer.getPluginsBoundByDefaultToAllLifecycles(DefaultLifecyclePluginAnalyzer.java:96)
              at org.apache.maven.model.plugin.DefaultLifecycleBindingsInjector.injectLifecycleBindings(DefaultLifecycleBindingsInjector.java:63)
              at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:397)
              at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:371)
              at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:560)
      

      The NullPointerException happens with most attempts to run the project, such as "mvn foo". I've attached the pom.xml, lifecycles.xml, components.xml, and the Java for the plugin. I think only components.xml is relevant.

        Attachments

        1. phase-test.tar
          50 kB
          John Riedl
        2. lifecycles.xml
          0.6 kB
          John Riedl
        3. components.xml
          0.8 kB
          John Riedl
        4. pom.xml
          0.6 kB
          John Riedl

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              riedl John Riedl
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: