Skip to content

NullPointerException under Maven 4.0.0-m10 #401

@nielsbasjes

Description

@nielsbasjes

Put this pom.xml in an empty directory:

<?xml version="1.0"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>nl.basjes.bugreport</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
          <execution>
            <id>Just say hello</id>
            <phase>validate</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>bash</executable>
              <arguments>
                <argument>-c</argument>
                <argument>echo Hello world</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

Doing mvn validate using maven 3.9.6 I get this

[INFO] --- exec:3.1.1:exec (Just say hello) @ problem ---
Hello world

Doing mvn validate using maven 4.0.0-m10 I get this (wrapped for readability)

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.1:exec (Just say hello) on project demo: 
    Execution Just say hello of goal org.codehaus.mojo:exec-maven-plugin:3.1.1:exec failed: 
    Cannot invoke "org.codehaus.plexus.PlexusContainer.lookup(String)" because the return value 
      of "org.apache.maven.execution.MavenSession.getContainer()" is null -> [Help 1]

The stacktrace where it fails:

Caused by: java.lang.NullPointerException: Cannot invoke "org.codehaus.plexus.PlexusContainer.lookup(String)" because the return value of "org.apache.maven.execution.MavenSession.getContainer()" is null
    at org.codehaus.mojo.exec.ExecMojo.getToolchain(ExecMojo.java:945)
    at org.codehaus.mojo.exec.ExecMojo.getExecutablePath(ExecMojo.java:751)
    at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:395)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:144)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2(MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:318)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:214)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:175)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions