Dockerfile-maven: NullPointerException in LoggingProgressHandler

Created on 27 Apr 2017  路  22Comments  路  Source: spotify/dockerfile-maven

I'm trying to use the dockerfile-maven plugin, but I haven't been able to get even the smallest example to work. Here's my Dockerfile:

FROM ubuntu:latest
CMD ["ls"]

Here's my 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>
    <artifactId>simple-docker</artifactId>
    <name>simple-docker</name>
    <groupId>com.example</groupId>
    <version>0.0.1</version>
    <build>
        <plugins>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>1.2.2</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <repository>tmp/junk</repository>
                    <tag>latest</tag>
                </configuration>
          </plugin>
        </plugins>
    </build>
</project>

And here's my output:

$ mvn -e package
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building simple-docker 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ simple-docker ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tpanning/Projects/deft-docker/owf/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ simple-docker ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ simple-docker ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/tpanning/Projects/deft-docker/owf/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ simple-docker ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ simple-docker ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ simple-docker ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: /home/tpanning/Projects/deft-docker/owf/target/simple-docker-0.0.1.jar
[INFO] 
[INFO] --- dockerfile-maven-plugin:1.2.2:build (default) @ simple-docker ---
[INFO] Building Docker context /home/tpanning/Projects/deft-docker/owf
[INFO] 
[INFO] Image will be built as tmp/junk:latest
[INFO] 
[INFO] Step 0 : FROM ubuntu:latest
[INFO] Trying to pull repository docker.io/library/ubuntu ... 
[INFO] Pulling from library/ubuntu
[INFO] Image 576b12d1aa01: Already exists
[INFO] Image b5ce920a148c: Already exists
[INFO] Image 274da7f89b05: Already exists
[INFO] Image 0346cecb4e51: Already exists
[INFO] Image 2e36b30057ab: Already exists
[INFO] Image f5bb94a8fac4: Already exists
[INFO] Digest: sha256:7c8894a0f32d3f1fadf086d18d12441ce0cd19295075af8dee34ce5e1f6c3ed1
[INFO] Status: Image is up to date for docker.io/ubuntu:latest
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.110 s
[INFO] Finished at: 2017-04-27T13:10:32-04:00
[INFO] Final Memory: 27M/202M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.2.2:build (default) on project simple-docker: Execution default of goal com.spotify:dockerfile-maven-plugin:1.2.2:build failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:dockerfile-maven-plugin:1.2.2:build (default) on project simple-docker: Execution default of goal com.spotify:dockerfile-maven-plugin:1.2.2:build failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    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: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: org.apache.maven.plugin.PluginExecutionException: Execution default of goal com.spotify:dockerfile-maven-plugin:1.2.2:build failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
Caused by: java.lang.NullPointerException
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
    at com.google.common.base.Splitter.split(Splitter.java:407)
    at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleGeneric(LoggingProgressHandler.java:84)
    at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:68)
    at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1162)
    at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1111)
    at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:152)
    at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:91)
    at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:206)
    at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:195)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    ... 21 more
[ERROR] 
[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

For reference, here's my version info:

$ mvn --version
Apache Maven 3.3.9 (NON-CANONICAL_2016-07-01T11:53:38Z_mockbuild; 2016-07-01T07:53:38-04:00)
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-1.b12.fc25.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.10.11-200.fc25.x86_64", arch: "amd64", family: "unix"
$ docker --version
Docker version 1.8.2.fc21, build 3abcea7-dirty

Am I missing or misconfiguring something?

All 22 comments

I'm getting this issue too.

This appears to be an error in the expectation of the progress message that's being passed to the LoggingProgressHandler. The message that is passed through at this point must have a null value returned from message.getStatus().

I've got no idea what's causing this, but a PR that checks the null value and uses some sort of default value in the logging handler would likely fix the issue.

I'm getting this NPE too. At least the image builds OK and works.

@snikch I agree with your diagnosis - I'm not familiar enough with the ProgressMessage stuff but I agree checking for null there would fix the issue.

@snikch @damianfanaro what version of docker are you running?

@mattnworb I'm running Docker version 1.8.2.fc21, build 3abcea7-dirty

@mattnworb 17.06.0-rc2-ce-mac14 (edge version).

Saw this issue in 17.06.0-rc2-ce-mac14 and 17.06.0-rc4-ce-mac15, backing down to 17.05.0-ce-mac11 I didn't see the problem anymore. (https://gist.github.com/franklinyu/5e0bb9d6c0d873f33c78415dd2ea4138 for old Mac versions)

Having the same issue with Mac Docker version Version 17.06.0-ce-rc5-mac16 (18400). After all the steps I described in the Dockerfile is successfully executed, but this one makes entire maven build fails.

I'm using 1.3.0 version and my maven (3.3.9) returns following error message with -X option.

[ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.0:build (default-cli) on project server: Execution default-cli of goal com.spotify:dockerfile-maven-plugin:1.3.0:build failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.0:build (default-cli) on project server: Execution default-cli of goal com.spotify:dockerfile-maven-plugin:1.3.0:build failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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: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: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.spotify:dockerfile-maven-plugin:1.3.0:build failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
at com.google.common.base.Splitter.split(Splitter.java:407)
at com.spotify.plugin.dockerfile.LoggingProgressHandler.handleGeneric(LoggingProgressHandler.java:83)
at com.spotify.plugin.dockerfile.LoggingProgressHandler.progress(LoggingProgressHandler.java:67)
at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1389)
at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1348)
at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:157)
at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:95)
at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:219)
at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more

And that problematic line is at LoggingProcessHandler line 83, and

https://github.com/spotify/dockerfile-maven/blob/master/plugin/src/main/java/com/spotify/plugin/dockerfile/LoggingProgressHandler.java#L83, and looks like input paramter is null value.

Changing the line to

for (String line : LINE_SPLITTER.split(Strings.nullToEmpty(value))) {

should work. ProgressMessage's status is defined with Nullable annotation, but handleGeneric() assumes it's not Nullable.

@freesoft thanks! would you mind to create a PR ?

I did create PR request https://github.com/spotify/dockerfile-maven/pull/30 and it seems TravisCI test is failing against jdk7 version, and I don't think it's related to my change but Travis CI configuration I guess? Can any of Spotify folk take a look? (@dflemstr?)

https://travis-ci.org/spotify/dockerfile-maven/builds/245858157

30 is now tested and ready to be accepted.

I get the same issue with Docker version 17.06.0-ce, build 02c1d87

I am glad that there is a fix for it. What is the estimated release date for this fix?

Yeah the new stable Docker release has broken this completely. Can we get a new release cut with this fix? I should add I'm seeing this on Linux.

Fix is released as part of 1.3.1. I tested it, but please confirm it works.

Confirmed; WFM on Linux. Thanks!

Confirmed; WFM on MacOS 10.12.5, Java8, Docker CE 17.06.00-ce-mac17 (18432), Maven 3.3.9.

I'm getting NPE on Windows 10, Version 17.06.0-ce-win18 (12627)

@wittyameta with what version of dockerfile-maven-plugin?

I get a NPE with Docker version 17.06.2-ce, build cec0b72 and dockerfile-maven-plugin 1.3.5.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  7Comments

NZhuravlev picture NZhuravlev  路  5Comments

rasmuslund picture rasmuslund  路  9Comments

yangguangftlp picture yangguangftlp  路  6Comments

sergiomazoodigeo picture sergiomazoodigeo  路  3Comments