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

NPE when using <external> #1253

Open
OndraZizka opened this issue Aug 14, 2019 · 10 comments
Open

NPE when using <external> #1253

OndraZizka opened this issue Aug 14, 2019 · 10 comments

Comments

@OndraZizka
Copy link

OndraZizka commented Aug 14, 2019

Description

When using <external>, DMP throws a NPE.
Following the docs at https://dmp.fabric8.io/#combining-property-config .

Info

  • d-m-p version : 0.31.0
  • Maven version (mvn -v) :
    Maven home: /sw/prog/maven-3.6.0
    Java version: 12.0.1, vendor: Oracle Corporation, runtime: /sw/prog/jdk/12.0.1
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "4.15.0-55-generic", arch: "amd64", family: "unix"

  • Docker version :Docker version 18.04.0-ce, build 3d479c0
  • If it's a bug, how to reproduce :
    It seems it's caused by lack of some expected property.
                <configuration>
                    <logDate>default</logDate>
                    <useColor>true</useColor>
                    <verbose>build</verbose>
                    <logStdout>true</logStdout>
                    <autoPull>true</autoPull>
                    <images>
                        <!-- RocketDB with Dev Tools. -->
                        <image>
                            <alias>centos7-devtools</alias>
                            <name>gitlab.k.arpage.ch:4999/ad-swiss/ad-epd/rocketdb:centos7-with-dev</name>
                            <external>
                                <type>properties</type>
                                <prefix>docker</prefix>
                                <mode>override</mode>
                            </external>
                            <build>
                                <tags></tags>
                                <from>centos:7</from>
                                <runCmds>
                                    <!-- set -e; set -o pipefail; shopt -s inherit_errexit; -->
                                    <run>yum update -y</run>
                                    <run>yum install -y curl wget unzip tree git openssl openssh-client</run>

                                    <run>mkdir -p /sw/ &amp;&amp; chmod a+rwx /sw/</run>
                                    <!--<run>yum -y install maven</run> Gives 3.0.5 -->
                                    <run>( \
                                        wget --no-verbose -O jdk12.tgz https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz; \
                                        tar xvzf jdk12.tgz -C /sw/; \
                                        rm jdk12.tgz; \
                                        rm -rf /sw/jdk12; \
                                        mv /sw/*jdk* /sw/jdk12; \
                                        java -version; \
                                    )</run>
                                    <!--
                                    echo 'export PATH="$PATH:/sw/jdk12/bin"' >> ~/.bashrc; \
                                    echo 'export JAVA_HOME=/sw/jdk12' >> ~/.bashrc; \
                                    export PATH="$PATH:/sw/jdk12/bin"; \
                                    -->

                                    <run>wget --no-verbose -O maven.zip http://www.pirbot.com/mirrors/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.zip</run>
                                    <run>unzip maven.zip -d /sw/</run>
                                    <run>rm maven.zip</run>
                                    <run>rm -rf /sw/maven</run>
                                    <run>mv /sw/apache-maven-* /sw/maven</run>
                                    <!--
                                    <run>echo 'export PATH="$PATH:/sw/maven/bin"' >> ~/.bashrc</run>
                                    <run>echo 'export M2_HOME=/sw/maven' >> ~/.bashrc</run>
                                    <run>export PATH="$PATH:/sw/maven/bin"</run>
                                    -->
                                    <run>mvn -v</run>
                                </runCmds>
                                <optimise>false</optimise>
                                <cmd>/bin/bash</cmd>
                            </build>
                            <run>
                                <env><JAVA_HOME>/sw/jdk12</JAVA_HOME></env>
                                <env><M2_HOME>/sw/maven</M2_HOME></env>
                                <env><PATH>$M2_HOME/bin:$JAVA_HOME/bin:$PATH</PATH></env>
                            </run>
                        </image>
                    </images>
                </configuration>
...
    <properties>
        <docker.env.PATH>/sw/jdk12:/sw/maven:$PATH</docker.env.PATH>
    </properties>

This throws:

Caused by: java.lang.NullPointerException
    at io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler.extractBuildConfiguration (PropertyConfigHandler.java:136)
    at io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler.resolve (PropertyConfigHandler.java:73)
    at io.fabric8.maven.docker.config.handler.ImageConfigResolver.resolve (ImageConfigResolver.java:98)
    at io.fabric8.maven.docker.AbstractDockerMojo$1.resolve (AbstractDockerMojo.java:331)
    at io.fabric8.maven.docker.config.ConfigHelper.resolveConfiguration (ConfigHelper.java:159)
    at io.fabric8.maven.docker.config.ConfigHelper.resolveImages (ConfigHelper.java:57)
    at io.fabric8.maven.docker.AbstractDockerMojo.initImageConfiguration (AbstractDockerMojo.java:325)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:224)
    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:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    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:567)
    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)

@spyderz42
Copy link

spyderz42 commented Oct 10, 2019

I had this happen to me as well. I fixed it, by moving away from external to docker.imagePropertyConfiguration = override in my top level pom, and docker.imagePropertyConfiguration = skip in the pom where I am setting some image build information such as name, tags, and contextDir.

I take this back.. setting the override in my top level pom ignored my Dockerfiles and completely broke my images

@rhuss
Copy link
Collaborator

rhuss commented Oct 11, 2019

There's a fix merged in recently which should solve this issue. Could you please try whether a d-m-p built from master does fix it for you ?

@OndraZizka
Copy link
Author

I can try when I get to dmp again, which will be in around few weeks. If that's ok.

@rhuss
Copy link
Collaborator

rhuss commented Oct 16, 2019

I can try when I get to dmp again, which will be in around few weeks. If that's ok.

No worries. We will have then probably already the next release, to you can directly test on a released version then.

@svenhaag
Copy link

svenhaag commented Nov 13, 2019

Same here with exact same version under Windows 10:

Caused by: java.lang.NullPointerException
    at io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler.extractBuildConfiguration (PropertyConfigHandler.java:140)
    at io.fabric8.maven.docker.config.handler.property.PropertyConfigHandler.resolve (PropertyConfigHandler.java:73)
    at io.fabric8.maven.docker.config.handler.ImageConfigResolver.resolve (ImageConfigResolver.java:98)
    at io.fabric8.maven.docker.AbstractDockerMojo$1.resolve (AbstractDockerMojo.java:331)
    at io.fabric8.maven.docker.config.ConfigHelper.resolveConfiguration (ConfigHelper.java:159)
    at io.fabric8.maven.docker.config.ConfigHelper.resolveImages (ConfigHelper.java:57)
    at io.fabric8.maven.docker.AbstractDockerMojo.initImageConfiguration (AbstractDockerMojo.java:325)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute (AbstractDockerMojo.java:224)
<image>
	<alias>app</alias>
	<name>foo/bar:latest</name>
	<build>
		<dockerFile>${project.build.directory}/work/docker/Dockerfile</dockerFile>
		<imagePullPolicy>Always</imagePullPolicy>
	</build>
	<external>
		<type>properties</type>
		<prefix>docker</prefix>
		<mode>override</mode>
	</external>
	<run>
		<ports>
			<port>docker.test.proxy.port:8443</port>
		</ports>
		<env>
			<ENABLE_DEBUG>true</ENABLE_DEBUG>
		</env>
		<wait>
			<http>
				<url>${docker.test.url}</url>
				<method>GET</method>
				<status>200</status>
			</http>
			<time>${docker.test.start.timout}</time>
		</wait>
		<log>
			<enabled>true</enabled>
			<color>cyan</color>
		</log>
	</run>
</image>

@svenhaag
Copy link

svenhaag commented Nov 13, 2019

There's a fix merged in recently which should solve this issue. Could you please try whether a d-m-p built from master does fix it for you ?

Can you please link the corresponding issue or commit fix? Thanks.

==> I think it's this one: #1274

@rohanKanojia
Copy link
Member

@svenhaag : Are you able to reproduce this error on a SNAPSHOT build of master of this plugin?

@svenhaag
Copy link

@svenhaag : Are you able to reproduce this error on a SNAPSHOT build of master of this plugin?

Yeah, indeed it works as expected. Thanks!

@rohanKanojia
Copy link
Member

@svenhaag : cool, it would be released soon

@rhuss
Copy link
Collaborator

rhuss commented Nov 21, 2019

Let's plan a release for the weekend.

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

No branches or pull requests

5 participants