0

I tried to run a container that build from azure pipeline and I have encountered with this error below. I run it on local and it works just fine and the pipeline builded successfully.

Error message when I tried to run a container

trigger:
  - azure-pipeline

pool:
  vmImage: 'ubuntu-18.04'

steps:
  - task: Maven@3
    inputs:
      mavenPomFile: 'pom.xml'

      mavenOptions: '-Xmx3072m'

      javaHomeOption: 'JDKVersion'

      jdkVersionOption: '1.8'

      jdkArchitectureOption: 'x64'

      publishJUnitResults: true

      testResultsFiles: '**/surefire-reports/TEST-*.xml'

      goals: 'package'

  - task: Maven@3

    displayName: Build Docker image

    inputs:

      mavenPomFile: 'pom.xml'

      goals: 'spring-boot:build-image'

      publishJUnitResults: false

      jdkVersionOption: '1.8'

  - task: Docker@2

    displayName: Push Docker image

    inputs:

      containerRegistry: 'flexible-benefit'

      repository: 'hub-web-services'

      command: 'push'

      tags: 'latest'

If anyone want more further information please comment down below and I will edit and add more information.

  • Does this answer your question? [How can I solve "java.lang.NoClassDefFoundError"?](https://stackoverflow.com/questions/17973970/how-can-i-solve-java-lang-noclassdeffounderror) – Ecstasy Jan 05 '22 at 09:31
  • No sure let me check, I can run the project locally but when I push to pipeline branch and it builded successfully and upload to azure container registry. I pull the image and It shows error like the above and I cant found the files that contain EnvironmentPostProcessor. I am desperate right now. – Suwatchai Nanchai Jan 05 '22 at 09:40
  • EnvironmentPostProcessor is part of springboot jars. This probably means that your app.jar <--Your application Jar being built is not actually containing your springboot libs. I would start with looking at your local target/app.jar, open it and see the jars inside of it and if it contains springboot jars.. Is it a Springboot far jar that you are building? – JCompetence Jan 05 '22 at 09:42
  • Yes it is jar file that I have builded – Suwatchai Nanchai Jan 05 '22 at 09:44
  • I found that the jar file that I have builded and artifactId didn't have a same name. Is it ok? – Suwatchai Nanchai Jan 05 '22 at 09:54

1 Answers1

0

There exists a task called the "Build and Push Image" in Azure Pipelines which can achieve the same thing as creating an image and pushing it to the container registry. All you need is to create a docker file specifying the jar location and specify the docker file path in the task. You can check online how to create a docker file, this will mostly solve your issue.