Gabriel Reid created MNG-5633:
---------------------------------

             Summary: NullPointerException when project contains cyclic 
references
                 Key: MNG-5633
                 URL: https://jira.codehaus.org/browse/MNG-5633
             Project: Maven 2 & 3
          Issue Type: Bug
            Reporter: Gabriel Reid


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
{code}
<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>
{code}

a/pom.xml
{code}
<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>
{code}

a/pom.xml
{code}
<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>
{code}

Running a simple maven command such as "mvn clean" results in the following:
{code}
$ 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
{code}





--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to