title: GKE: cannot main class not found
body: <p>I am trying to deploy a containerized Spring Boot application in GKE. The deployment is successful but the pod goes into CrashLoopBackOff. I find the error : Exception in thread &quot;main&quot; java.lang.ClassNotFoundException: com.xx.yy.api.Application</p>
  <p>Application class is a valid SpringBoot Main class.</p>
  <pre><code>package com.xx.yy.api;
  
  @SpringBootApplication(exclude  = SecurityAutoConfiguration.class)
  @EnableCaching
  public class Application {
  
  public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  <p>My pom.xml is:</p>
  <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.xx.yy.api&lt;/groupId&gt;
      &lt;artifactId&gt;my-api&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;name&gt;My API&lt;/name&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;2.2.4.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt;
      &lt;/parent&gt;
      &lt;properties&gt;
          &lt;start-class&gt;com.xx.yy.api.Application&lt;/start-class&gt;
          
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;maven.compiler.target&gt;${java.version}&lt;/maven.compiler.target&gt;
          &lt;maven.compiler.source&gt;${java.version}&lt;/maven.compiler.source&gt;
  
          &lt;!-- Maven --&gt;
          &lt;maven-surefire-plugin.version&gt;3.0.0-M3&lt;/maven-surefire-plugin.version&gt;
          &lt;maven-failsafe-plugin.version&gt;3.0.0-M3&lt;/maven-failsafe-plugin.version&gt;
          &lt;maven-compiler-plugin.version&gt;3.6.1&lt;/maven-compiler-plugin.version&gt;
  
          &lt;org.projectlombok.version&gt;1.18.4&lt;/org.projectlombok.version&gt;
          &lt;org.mapstruct.version&gt;1.3.1.Final&lt;/org.mapstruct.version&gt;
  
          &lt;!-- Junit &amp; Jacoco --&gt;
          &lt;jacoco.ut.execution.data.file&gt;${project.build.directory}/coverage-reports/jacoco-ut.exec&lt;/jacoco.ut.execution.data.file&gt;
          &lt;jacoco-plugin.version&gt;0.8.4&lt;/jacoco-plugin.version&gt;
          &lt;junit.jupiter.version&gt;5.3.2&lt;/junit.jupiter.version&gt;
          &lt;mockito.version&gt;3.2.4&lt;/mockito.version&gt;
          &lt;junit.platform.version&gt;1.5.1&lt;/junit.platform.version&gt;
  
          &lt;!-- Sonar --&gt;
          &lt;sonar-maven-plugin.version&gt;3.5.0.1254&lt;/sonar-maven-plugin.version&gt;
          &lt;sonar.java.coveragePlugin&gt;jacoco&lt;/sonar.java.coveragePlugin&gt;
          &lt;sonar.dynamicAnalysis&gt;reuseReports&lt;/sonar.dynamicAnalysis&gt;
          &lt;sonar.jacoco.reportPaths&gt;${jacoco.ut.execution.data.file}&lt;/sonar.jacoco.reportPaths&gt;
          &lt;sonar.language&gt;java&lt;/sonar.language&gt;
          &lt;sonar.projectName&gt;my-api&lt;/sonar.projectName&gt;
          &lt;sonar.coverage.exclusions&gt;
              **/com/xx/yy/api/persistence/entity/**.*,
              **/com/xx/yy/api/dto/**.*
          &lt;/sonar.coverage.exclusions&gt;
  
          &lt;!-- Encoding --&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;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;junit&lt;/groupId&gt;
                      &lt;artifactId&gt;junit&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
              &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
              &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.assertj&lt;/groupId&gt;
              &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-testing&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;log4j&lt;/groupId&gt;
                      &lt;artifactId&gt;log4j&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.tngtech.archunit&lt;/groupId&gt;
              &lt;artifactId&gt;archunit-junit4&lt;/artifactId&gt;
              &lt;version&gt;0.9.3&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
              &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-test-autoconfigure&lt;/artifactId&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-starter-data-jpa&lt;/artifactId&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.apache.tomcat&lt;/groupId&gt;
                      &lt;artifactId&gt;tomcat-jdbc&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
              &lt;artifactId&gt;mapstruct&lt;/artifactId&gt;
              &lt;version&gt;${org.mapstruct.version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.1.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;private.com&lt;/groupId&gt;
              &lt;artifactId&gt;logback-logging&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-oauth2-jose&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.nimbusds&lt;/groupId&gt;
              &lt;artifactId&gt;nimbus-jose-jwt&lt;/artifactId&gt;
              &lt;version&gt;8.4&lt;/version&gt;
          &lt;/dependency&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-oauth2-resource-server&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-oauth2-client&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.json&lt;/groupId&gt;
              &lt;artifactId&gt;json&lt;/artifactId&gt;
              &lt;version&gt;20180813&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jaxb&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-runtime&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.querydsl&lt;/groupId&gt;
              &lt;artifactId&gt;querydsl-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.querydsl&lt;/groupId&gt;
              &lt;artifactId&gt;querydsl-apt&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.querydsl&lt;/groupId&gt;
              &lt;artifactId&gt;querydsl-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- Only required to run tests in an IDE that bundles an older version --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.junit.platform&lt;/groupId&gt;
              &lt;artifactId&gt;junit-platform-launcher&lt;/artifactId&gt;
              &lt;version&gt;${junit.platform.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.mockito&lt;/groupId&gt;
              &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
              &lt;version&gt;${mockito.version}&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;directory&gt;target&lt;/directory&gt;
          &lt;finalName&gt;my-api&lt;/finalName&gt;
          &lt;sourceDirectory&gt;${basedir}/src/main/java&lt;/sourceDirectory&gt;
  
          &lt;pluginManagement&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.sonarsource.scanner.maven&lt;/groupId&gt;
                      &lt;artifactId&gt;sonar-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${sonar-maven-plugin.version}&lt;/version&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${maven-surefire-plugin.version}&lt;/version&gt;
                  &lt;/plugin&gt;
                  &lt;!-- Runs integration tests --&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${maven-failsafe-plugin.version}&lt;/version&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                      &lt;version&gt;${maven-compiler-plugin.version}&lt;/version&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/pluginManagement&gt; 
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;${java.version}&lt;/source&gt;
                      &lt;target&gt;${java.version}&lt;/target&gt;
                      &lt;annotationProcessorPaths&gt;
                          &lt;path&gt;
                              &lt;groupId&gt;org.mapstruct&lt;/groupId&gt;
                              &lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt;
                              &lt;version&gt;${org.mapstruct.version}&lt;/version&gt;
                          &lt;/path&gt;
                          &lt;path&gt;
                              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
                              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
                              &lt;version&gt;${org.projectlombok.version}&lt;/version&gt;
                          &lt;/path&gt;
                      &lt;/annotationProcessorPaths&gt;
                      &lt;compilerArgs&gt;
                          &lt;compilerArg&gt;-Amapstruct.suppressGeneratorTimestamp=true&lt;/compilerArg&gt;
                          &lt;compilerArg&gt;-Amapstruct.suppressGeneratorVersionInfoComment=true&lt;/compilerArg&gt;
                          &lt;compilerArg&gt;-Amapstruct.defaultComponentModel=spring&lt;/compilerArg&gt;
                      &lt;/compilerArgs&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
                          &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
                          &lt;version&gt;${junit.jupiter.version}&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          
              &lt;!-- Jacoco : code coverage --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                  &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;${jacoco-plugin.version}&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;pre-unit-test&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;prepare-agent&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;destFile&gt;${jacoco.ut.execution.data.file}&lt;/destFile&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;post-unit-test&lt;/id&gt;
                          &lt;phase&gt;test&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;report&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;dataFile&gt;${jacoco.ut.execution.data.file}&lt;/dataFile&gt;
                              &lt;outputDirectory&gt;${project.reporting.outputDirectory}/jacoco-ut&lt;/outputDirectory&gt;
                              &lt;excludes&gt;
                                  &lt;exclude&gt;**/com/xx/yy/api/persistence/entity/**.*&lt;/exclude&gt;
                                  &lt;exclude&gt;**/com/xx/yy/api/dto/**.*&lt;/exclude&gt;
                              &lt;/excludes&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;mainClass&gt;${start-class}&lt;/mainClass&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
               &lt;!-- JPA Query DSL  --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;com.mysema.maven&lt;/groupId&gt;
                  &lt;artifactId&gt;apt-maven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;process&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;target/generated-sources/java&lt;/outputDirectory&gt;
                              &lt;processor&gt;com.querydsl.apt.jpa.JPAAnnotationProcessor&lt;/processor&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt; 
          &lt;/plugins&gt;
      &lt;/build&gt;
  
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;artifactory&lt;/id&gt;
              &lt;url&gt;https://artifactory.dt.xx.com/artifactory/nexus-dt-proxy/&lt;/url&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
  &lt;/project&gt;
  </code></pre>
  <p>The docker file I am using:</p>
  <pre><code>FROM maven:3.5-jdk-8 as builder
  
  ARG http_proxy
  ARG HTTP_PROXY_HOST
  ARG HTTP_PROXY_PORT
  ARG MAVEN_SETTINGS_XML=&quot;settings_cicd.xml&quot;
  ARG TARGET=&quot;deploy&quot;
  ARG artifactory_username
  ARG artifactory_apikey
  
  
  WORKDIR /api/
  
  COPY ./settings_cicd.xml /api/
  COPY ./pom.xml /api/
  COPY ./src /api/
  
  RUN echo &quot;MAVEN_SETTINGS_XML = $MAVEN_SETTINGS_XML&quot;
  
  RUN sed 's/PLACEHOLDER_ARTIFACTORY_USER/'&quot;${artifactory_username}&quot;'/' ${MAVEN_SETTINGS_XML} &gt; tmp.settings.xml &amp;&amp;\
      sed 's/PLACEHOLDER_ARTIFACTORY_APIKEY/'&quot;${artifactory_apikey}&quot;'/' tmp.settings.xml &gt; ${MAVEN_SETTINGS_XML} &amp;&amp;\
      mvn clean install -DskipTests -Dtarget=${TARGET} -e -q -s ${MAVEN_SETTINGS_XML}
  
  
  FROM openjdk:8-jre-alpine
  
  
  VOLUME /tmp
  
  COPY --from=builder /api/target/my-api.jar /home/project/my-api.jar
  
  ARG http_proxy
  ARG https_proxy
  ARG TAG_VERSION
  ARG TAG_BUILD
  ARG TAG_COMMIT 
  
  RUN apk update &amp;&amp; apk --no-cache add curl bash
  RUN ln -sf /bin/bash /bin/sh
  RUN addgroup -g 1000 user \
      &amp;&amp; adduser -u 1000 -G user -s /bin/bash -D user
  
  EXPOSE 8080
  
  ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;/home/project/my-api.jar&quot;]
  </code></pre>
  <p>Can't figure out what is going wrong. I have tested the Spring Boot jar separately it works. I am yet to test the container separately. Any leads will help.</p>