Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jib-maven-plugin:2.5.0:build failed - NullPointerException in getSpringBootRepackageConfiguration #2687

Closed
tomikmar opened this issue Aug 10, 2020 · 4 comments · Fixed by #2688
Assignees
Milestone

Comments

@tomikmar
Copy link

tomikmar commented Aug 10, 2020

Environment:

  • Jib version: 2.5.0
  • Build tool: maven:3.6.3-amazoncorretto-11
  • OS: Amazon Linux 2

Description of the issue:

After upgrading from 2.4.0 to 2.5.0 we have NullPointerException during build. It looks that the issue is in getSpringBootRepackageConfiguration when spring-boot-maven-plugin configuration section is not provided.

Steps to reproduce:

Use spring-boot-maven-plugin without configuration section (we also don't have this section in our parent pom):

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

Workaround:

Just add configuration (may be empty):

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration></configuration>
        </plugin>

Log output:

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build (default-cli) on project my-service: Execution default-cli of goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build (default-cli) on project notification-sender-service: Execution default-cli of goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    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)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    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)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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.Objects.requireNonNull (Objects.java:221)
    at java.util.Optional.<init> (Optional.java:107)
    at java.util.Optional.of (Optional.java:120)
    at com.google.cloud.tools.jib.maven.MavenProjectProperties.getSpringBootRepackageConfiguration(MavenProjectProperties.java:571)
    at com.google.cloud.tools.jib.maven.MavenProjectProperties.getJarArtifact (MavenProjectProperties.java:524)
    at com.google.cloud.tools.jib.maven.MavenProjectProperties.createJibContainerBuilder (MavenProjectProperties.java:283)
    at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.processCommonConfiguration (PluginConfigurationProcessor.java:398)
    at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.processCommonConfiguration (PluginConfigurationProcessor.java:455)
    at com.google.cloud.tools.jib.plugins.common.PluginConfigurationProcessor.createJibBuildRunnerForRegistryImage (PluginConfigurationProcessor.java:274)
    at com.google.cloud.tools.jib.maven.BuildImageMojo.execute (BuildImageMojo.java:102)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    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)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    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)
[ERROR] 

Additional Information:

It may be connected with #2565

@chanseokoh chanseokoh self-assigned this Aug 10, 2020
@chanseokoh
Copy link
Member

Sorry, this is from #2526.

I can't reproduce this. (I am interested in seeing a reproducible sample project to understand why this can happen so that we can prevent similar issues in the future, but it's totally up to you.) However, it's an easy fix anyway.

@chanseokoh
Copy link
Member

chanseokoh commented Aug 10, 2020

@tomikmar we just released Jib Maven 2.5.1 with the fix.

UPDATE: the fix in 2.5.1 is problematic. Use Jib Maven 2.5.2.

@chanseokoh chanseokoh added this to the v2.5.0 milestone Aug 10, 2020
@tomikmar
Copy link
Author

Thanks for the fix. This is the minimal example (3 files) that you can use to reproduce the issue.

Command:

mvn clean package jib:build -am -projects my-service

jib-error\pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test.error</groupId>
    <artifactId>jib-error</artifactId>
    <version>0.1.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <jdk.version>11</jdk.version>
        <java.version>11</java.version>
        <java.compiler.release>11</java.compiler.release>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <modules>
        <module>my-service</module>
    </modules>

    <build>
        <plugins>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>2.3.1.RELEASE</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>jib-maven-plugin</artifactId>
                    <version>2.5.0</version>
                    <configuration>
                        <from>
                            <image>dockerreg.abc.com/def/build/my-app-base-image:latest</image>
                        </from>
                        <to>
                            <image>dockerreg.abc.com/def/backend/my-${project.artifactId}</image>
                        </to>
                        <containerizingMode>packaged</containerizingMode>
                        <skip>true</skip>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

jib-error\my-service\pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>my-service</artifactId>
    <packaging>jar</packaging>


    <parent>
        <groupId>com.test.error</groupId>
        <artifactId>jib-error</artifactId>
        <version>0.1.1-SNAPSHOT</version>
    </parent>

    <dependencies>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
<!--                <configuration>-->
<!--                    <finalName>$f{project.artifactId}</finalName>-->
<!--                </configuration>-->
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                    <container>
                        <entrypoint>/wrapper.sh, com.test.error.MyServiceApplication</entrypoint>
                    </container>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

jib-error\my-service\src\main\java\MyService.java

public class MyService {
    public static void main(final String[] args) { }
}

Maven

mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\java\apache-maven-3.6.3\bin\..
Java version: 11.0.5, vendor: Amazon.com Inc., runtime: C:\Program Files\Amazon Corretto\jdk11.0.5_10
Default locale: en_US, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Logs

[INFO] --- spring-boot-maven-plugin:2.3.1.RELEASE:repackage (default) @ my-service ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- jib-maven-plugin:2.5.0:build (default-cli) @ my-service ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for jib-error 0.1.1-SNAPSHOT:
[INFO]
[INFO] jib-error .......................................... SUCCESS [  1.294 s]
[INFO] my-service ......................................... FAILURE [  3.048 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.003 s
[INFO] Finished at: 2020-08-11T14:38:34+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.5.0:build (default-cli) on project my-service: Execution default-cli of goal com.google.cloud.tools:jib-maven-p
lugin:2.5.0:build failed.: NullPointerException -> [Help 1]
[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/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :my-service

@chanseokoh
Copy link
Member

Thanks for the sample. I guess the issue is reproducible when

  • A parent POM defines <pluginManagement> (with spring-boot-maven-plugin in it).
  • A child module inherits the parent POM and have no <configuration> in spring-boot-maven-plugin.

OTOH, I wasn't able to reproduce it with the usual Spring Boot quickstart project whose parent POM points to org.springframework.boot:spring-boot-starter-parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants