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

NullPointerException during mvn install when property is called "project.version"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.6.3
    • 3.8.1
    • None

    Description

      Use the following (simplified) pom.xml and run mvn install:

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.example</groupId>
        <artifactId>foo</artifactId>
        <version>${revision}</version>
        <properties>
          <project.version>1.0</project.version>
          <revision>${project.version}</revision>
        </properties>
      </project>

      It will throw the following exception:

       [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:120)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
          at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke (Method.java:498)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
      Caused by: java.lang.NullPointerException
          at java.util.Hashtable$Entry.setValue (Hashtable.java:1286)
          at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:1429)
          at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:1027)
          at org.apache.maven.model.interpolation.StringVisitorModelInterpolator$ModelVisitor.visit (StringVisitorModelInterpolator.java:170)
          at org.apache.maven.model.interpolation.StringVisitorModelInterpolator.interpolateModel (StringVisitorModelInterpolator.java:107)
          at org.apache.maven.model.building.DefaultModelBuilder.interpolateModel (DefaultModelBuilder.java:789)
          at org.apache.maven.model.building.DefaultModelBuilder.build (DefaultModelBuilder.java:393)
          at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:448)
          at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:414)
          at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:377)
          at org.apache.maven.graph.DefaultGraphBuilder.collectProjects (DefaultGraphBuilder.java:414)
          at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor (DefaultGraphBuilder.java:405)
          at org.apache.maven.graph.DefaultGraphBuilder.build (DefaultGraphBuilder.java:82)
          at org.apache.maven.DefaultMaven.buildGraph (DefaultMaven.java:507)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:219)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)

      This is only happening when I name the property `project.version` indicating that this might be an illegal name. I can switch it to `project.ver` and it works fine.

      This should not throw a NullPointerException but instead either work or throw an appropriate exception.

      Attachments

        Issue Links

          Activity

            People

              slachiewicz Sylwester Lachiewicz
              daniel.langerenken@gmail.com Daniel Langerenken
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: