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

NullPointerException when project contains cyclic references

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None
    • None
    • Patch

    Description

      Using maven 3.2.1, when a project has a cyclic dependency between modules, a NullPointerException is thrown.

      The situation is that there is a root pom that references two modules, a and b. Module a is dependent on b, and module b is dependent on a.

      The relevant portions of the poms are as follows:

      root pom

      <project>
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>test</groupId>
        <artifactId>invalid</artifactId>
        <version>0.1-SNAPSHOT</version>
        <packaging>pom</packaging>
      
        <modules>
          <module>a</module>
          <module>b</module>
        </modules>
      
        <dependencyManagement>
          <dependencies>
          <dependency>
            <groupId>test</groupId>
            <artifactId>a</artifactId>
            <version>${project.version}</version>
          </dependency>
          <dependency>
            <groupId>test</groupId>
            <artifactId>b</artifactId>
            <version>${project.version}</version>
          </dependency>
          </dependencies>
        </dependencyManagement>
      </project>
      

      a/pom.xml

      <project>
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>test</groupId>
        <artifactId>a</artifactId>
      
        <parent>
          <groupId>test</groupId>
          <artifactId>invalid</artifactId>
          <version>0.1-SNAPSHOT</version>
        </parent>
        <dependencies>
          <dependency>
            <groupId>test</groupId>
            <artifactId>b</artifactId>
          </dependency>
        </dependencies>
      </project>
      

      a/pom.xml

      <project>
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>test</groupId>
        <artifactId>b</artifactId>
      
        <parent>
          <groupId>test</groupId>
          <artifactId>invalid</artifactId>
          <version>0.1-SNAPSHOT</version>
        </parent>
        <dependencies>
          <dependency>
            <groupId>test</groupId>
            <artifactId>a</artifactId>
          </dependency>
        </dependencies>
      </project>
      

      Running a simple maven command such as "mvn clean" results in the following:

      $ mvn clean
      [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:167)
      	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
      	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
      	at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
      	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
      Caused by: java.lang.NullPointerException
      	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:270)
      	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
      	... 11 more
      [ERROR] 
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR] 
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException
      

      Attachments

        1. MNG-5633.patch
          0.9 kB
          Gabriel Reid

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gabrielreid Gabriel Reid
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: