<p>I am trying to push a spring boot created microservice to an ibm cloud hosted K8 cluster but am constantly getting the below error on startup:</p>

<pre><code>Error: Invalid or corrupt jarfile /app.jar
</code></pre>

<p>My dockerfile:</p>

<pre><code>FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
</code></pre>

<p>my pom.xml:</p>

<pre><code>&lt;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"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;projects&lt;/groupId&gt;
  &lt;artifactId&gt;mydb2jdbcproject&lt;/artifactId&gt;
  &lt;version&gt;1&lt;/version&gt;

  &lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
    &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
    &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
    &lt;java.version&gt;1.8&lt;/java.version&gt;
    &lt;spring-cloud.version&gt;Dalston.SR4&lt;/spring-cloud.version&gt;
    &lt;docker.image.prefix&gt;springio&lt;/docker.image.prefix&gt;
    &lt;app.name&gt;mydb2jdbcproject&lt;/app.name&gt;
  &lt;/properties&gt;

  &lt;parent&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
    &lt;version&gt;1.5.15.RELEASE&lt;/version&gt;
  &lt;/parent&gt;

  &lt;dependencies&gt;
  &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.ibm.db2.jcc&lt;/groupId&gt;
      &lt;artifactId&gt;db2jcc4&lt;/artifactId&gt;
      &lt;version&gt;4.26.14&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-actuator&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-hystrix&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
      &lt;scope&gt;test&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;javax.json&lt;/groupId&gt;
      &lt;artifactId&gt;javax.json-api&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
      &lt;artifactId&gt;json-path&lt;/artifactId&gt;
      &lt;version&gt;2.4.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;com.ibm.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;ibm-cloud-spring-boot-service-bind&lt;/artifactId&gt;
      &lt;version&gt;1.1.1&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.microprofile.config&lt;/groupId&gt;
      &lt;artifactId&gt;microprofile-config-api&lt;/artifactId&gt;
      &lt;version&gt;1.1&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;dependencyManagement&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
        &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
        &lt;version&gt;${spring-cloud.version}&lt;/version&gt;
        &lt;type&gt;pom&lt;/type&gt;
        &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;

  &lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;repo&lt;/id&gt;
      &lt;url&gt;file://${project.basedir}/lib&lt;/url&gt;
    &lt;/repository&gt;
  &lt;/repositories&gt;

  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;com.spotify&lt;/groupId&gt;
        &lt;artifactId&gt;dockerfile-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.4.9&lt;/version&gt;
        &lt;configuration&gt;
          &lt;repository&gt;${docker.image.prefix}/${project.artifactId}&lt;/repository&gt;
          &lt;buildArgs&gt;
            &lt;JAR_FILE&gt;target/${project.build.finalName}.jar&lt;/JAR_FILE&gt;
          &lt;/buildArgs&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
        &lt;plugin&gt;
  &lt;groupId&gt;io.fabric8&lt;/groupId&gt;
  &lt;artifactId&gt;docker-maven-plugin&lt;/artifactId&gt;
  &lt;extensions&gt;true&lt;/extensions&gt;
  &lt;configuration&gt;
    &lt;images&gt;
      &lt;image&gt;
        &lt;name&gt;us.icr.io/rbs1/rbstest&lt;/name&gt;
        &lt;build&gt;
          &lt;from&gt;adoptopenjdk/openjdk8-openj9&lt;/from&gt;
          &lt;entryPoint&gt;
            &lt;exec&gt;
              &lt;arg&gt;java&lt;/arg&gt;
              &lt;arg&gt;-jar&lt;/arg&gt;
              &lt;arg&gt;/${project.build.finalName}.jar&lt;/arg&gt;
            &lt;/exec&gt;
          &lt;/entryPoint&gt;
          &lt;assembly&gt;
            &lt;targetDir&gt;/&lt;/targetDir&gt;
            &lt;mode&gt;dir&lt;/mode&gt;
            &lt;descriptorRef&gt;artifact&lt;/descriptorRef&gt;
          &lt;/assembly&gt;
        &lt;/build&gt;
      &lt;/image&gt;
    &lt;/images&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;

&lt;/project&gt;'
</code></pre>

<p>my event log:</p>

<pre><code>Events:
  Type     Reason     Age                    From                    Message
  ----     ------     ----                   ----                    -------
  Normal   Scheduled  9m10s                  default-scheduler       Successfully assigned default/basic-deployment-768559cfc6-6fd2j to 10.144.195.59
  Normal   Created    8m15s (x4 over 9m)     kubelet, 10.144.195.59  Created container
  Normal   Started    8m15s (x4 over 9m)     kubelet, 10.144.195.59  Started container
  Normal   Pulling    7m35s (x5 over 9m8s)   kubelet, 10.144.195.59  pulling image "------/---------"
  Normal   Pulled     7m34s (x5 over 9m)     kubelet, 10.144.195.59  Successfully pulled image "--------/---------"
  Warning  BackOff    4m6s (x24 over 8m57s)  kubelet, 10.144.195.59  Back-off restarting failed container
</code></pre>

<p>The images are held in a docker repository and then pulled into the cluster. I am fully logged in to both docker and ibmcloud. Each time the container restarts 6 times but is always unsuccessful. I run </p>

<pre><code>mvn package
</code></pre>

<p>every time before i build the docker image to make sure there is a jar available and the jar is held with in the target folder named mydb2jdbcproject-1. </p>

Tristan O'Keefe
<p>Rather embarrassingly i hadn't realised that i needed to point towards the right jar file with <code>${JAR_FILE}</code>. After ensuring it was directed at my app jar it all worked. Thankyou!</p>

<p>Keeping here incase someone needs it.</p>
