Welcome to the Linux Foundation Forum!

Section 5 Revision control with GIT - mvn build failed

Options

Is anyone can provide the zip file generated by the start.spring.io page and share the exact mvn:alpine version? I do not know java, so rather than wasting time trying to understand why the build failed I wish I could get the same source and version used in the video.

Answers

  • luisviveropena
    Options

    Hi @bauger,

    If you provide details about your environment (local, cloud, OS and version), the command you ran and the error you experienced, I may try to reproduce it.

    Regards,
    Luis.

  • bauger
    bauger Posts: 39
    Options

    Hi Luis,

    please see below. Thanks for your help.

    Beatrice

    • OS

    $ uname -srm

    Linux 4.19.0-18-amd64 x86_64

    • Docker version

    $ sudo docker version

    Client: Docker Engine - Community
    Version: 20.10.12
    API version: 1.41
    Go version: go1.16.12
    Git commit: e91ed57
    Built: Mon Dec 13 11:45:37 2021
    OS/Arch: linux/amd64
    Context: default
    Experimental: true

    Server: Docker Engine - Community
    Engine:
    Version: 20.10.12
    API version: 1.41 (minimum version 1.12)
    Go version: go1.16.12
    Git commit: 459d0df
    Built: Mon Dec 13 11:43:46 2021
    OS/Arch: linux/amd64
    Experimental: false
    containerd:
    Version: 1.4.12
    GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
    runc:
    Version: 1.0.2
    GitCommit: v1.0.2-0-g52b36a2
    docker-init:
    Version: 0.19.0
    GitCommit: de40ad0

    $ sudo docker container run --rm -it -v m2:/root/.m2 -v /home/bea/Lecture/Learning/LinuxFoundation/DevOps_Bootcamp/LFS261/git/hellocd:/app maven:alpine mvn spring-boot:run -f app/pom.xml

    and outputs:

    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------< com.example:hellocd >-------------------------
    [INFO] Building hellocd 0.0.1-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO]
    [INFO] >>> spring-boot-maven-plugin:2.6.3:run (default-cli) > test-compile @ hellocd >>>
    [INFO]
    [INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ hellocd ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Using 'UTF-8' encoding to copy filtered properties files.
    [INFO] Copying 1 resource
    [INFO] Copying 0 resource
    [INFO]
    [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ hellocd ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 1 source file to /app/target/classes
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.516 s
    [INFO] Finished at: 2022-02-09T17:50:35Z
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project hellocd: Fatal error compiling: invalid target release: 11 -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [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/MojoExecutionException

  • luisviveropena
    Options

    Hi Beatrice,

    Sorry for taking long in providing feedback, but it's not so easy to do the tests.
    I was able to reproduce the issue on Ubuntu 20.04.4 LTS. What distro and version did you tried with?

    Regards,
    Luis.

  • bauger
    bauger Posts: 39
    Options

    Hi Luis,

    thanks for taking time trying to reproduce the issue on your end. I'm running docker on Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux.

    I finally used another alpine version to be able to continue following the tutorial.

    Béatrice

  • luisviveropena
    Options

    Hi Béatrice,

    It's a pleasure! Can you tell me what Alpine version worked for you, please?

    Thanks,
    Luis.

  • bauger
    bauger Posts: 39
    Options

    Hi Luis,

    unfortunately this section is before the Jenkins introduction, so I do not have any script to check. And due to resources constraint I had to prune Docker images no longer used. I'm afraid I cannot trace back with alpine version I used for sure. But, in the following section where the Docker image is written in a Jenkinsfile I used the maven:3.6.1-jdk-8-alpine.

    Thanks

    Béatrice

  • luisviveropena
    luisviveropena Posts: 1,173
    Options

    Hi Béatrice,

    Yep, the deployments are sensitive to different versions. We keep investigating in our end.

    Regards,
    Luis.

  • gouravshah
    gouravshah Posts: 139
    Options

    Thanks for pitching in @luisviveropena . @bauger maven:3.8-openjdk-11-slim image tag works with the latest version of the code. I have updated the lab guide and should be published soon.

  • luisviveropena
    luisviveropena Posts: 1,173
    Options

    It's a pleasure, @gouravshah .

    I have updated the lab guide and should be published soon.

    Wonderful!

    Luis.

  • manuel.nhiuana
    Options

    Hi,
    I'm also experiencing issues compiling the build. The solution is to use maven:3.8-openjdk-11 image?
    attached the file with more details.

    executed:
    $ docker container run --rm -it -v m2:/root/.m2 -v /home/admin/Documents/Bootcamp/DevOps_SRE/Git/hellocd:/app maven:alpine mvn spring-boot:run -f /app/pom.xml -X

    Image:

    REPOSITORY TAG IMAGE ID CREATED SIZE
    maven alpine 7445f83cd169 2 years ago 122MB

  • manuel.nhiuana
    manuel.nhiuana Posts: 12
    edited March 2022
    Options

    I can confirm, it works with image maven:3.8-openjdk-11-slim , solution pointed by @gouravshah

    @manuel.nhiuana said:
    Hi,
    I'm also experiencing issues compiling the build. The solution is to use maven:3.8-openjdk-11 image?
    attached the file with more details.

    executed:
    $ docker container run --rm -it -v m2:/root/.m2 -v /home/admin/Documents/Bootcamp/DevOps_SRE/Git/hellocd:/app maven:alpine mvn spring-boot:run -f /app/pom.xml -X

    Image:

    REPOSITORY TAG IMAGE ID CREATED SIZE
    maven alpine 7445f83cd169 2 years ago 122MB

  • luisviveropena
    luisviveropena Posts: 1,173
    Options

    Hi @manuel.nhiuana , yes, maven:3.8-openjdk-11-slim is the version that Gourav tested and confirmed it's working :)

    I'm glad it worked for you too.

    Many regards,
    Luis.

  • zacts
    zacts Posts: 14
    edited December 2022
    Options

    Hello,

    I encountered this build issue today as well (2022.12.13). I did find a fix for it. I decided to use OpenJDK-17 instead of OpenJDK-11 when creating the spring zip file, and then I used maven:3.8.5-openjdk-17-slim with docker. It worked after that.

    I hope this might help anyone else too.

    Thanks,

    --

    zak

  • luisviveropena
    Options

    Hi @zacts,

    1.- Are you working with the updated course/content?
    2.- What is the specific section on the chapter and the command that failed to you? So I can check on it.

    Regards,
    Luis.

  • ericegan
    ericegan Posts: 31
    edited December 2022
    Options

    Hopefully that image came through, but basically, be sure to choose 11 for the Java version at the bottom of the Spring Initializr (sic) page for it to work with Java 11. Otherwise good job on figuring out your own issue with Java 17! @zacts

  • zacts
    zacts Posts: 14
    Options

    Hello,

    1. I'm working through the PDF of Lab 3 for the ch on git in the DevOps and SRE Fundamentals course. I accessed this PDF as of Monday 2022.12.12.
    2. The specific section and commands that failed for me are Using Docker in Development
      bash-$ docker container run --rm -it -v /absolute/path/to/hellocd:/app maven:3.8-openjdk-11-slim sh
      bash-# mvn spring-boot:run -f app/pom.xml

    after running the mvn spring-boot:run -f app/pom.xml the build fails with an error due to a version mismatch or something. I have to try it out again later today as I don't have my vm instance handy at the moment. The version mismatch seemed to want OpenJDK 17. So, my fix was to try to generate the zip file with OpenJDK-17 instead of OpenJDK-11 and then to use the corresponding dockerhub maven version for that. It did successfully complete the build for me after I did that.

    Hi @zacts,

    1.- Are you working with the updated course/content?
    2.- What is the specific section on the chapter and the command that failed to you? So I can check on it.

    Regards,
    Luis.

  • ericegan
    Options

    @zacts please see my suggestion above your last comment. Sorry, I didn't tag you the first time. I edited my comment above to tag you in it.

  • zacts
    zacts Posts: 14
    edited December 2022
    Options

    I originally used Java-11 like in your post, but that was throwing a version mismatch error for me when I tried to build it. I switched to generating the zip file via Java-17 instead of Java-11 and then I used a more recent dockerhub maven with OpenJDK-17-slim instead of OpenJDK-11-slim and the build worked for me.

    @ericegan said:
    @zacts please see my suggestion above your last comment. Sorry, I didn't tag you the first time. I edited my comment above to tag you in it.

  • ericegan
    Options

    @zacts Thanks for catching this! It appears to be a mistake on Spring Boot's side. They updated the site a couple of weeks ago and appear to have mixed up their versions on accident. I have opened an issue with them on their GitHub but in the mean time you are fine completing the lab with the Java 17 image as you have discovered on your own. Wherever you see maven:3.8-openjdk-11-slim, replace it with maven:3.8-openjdk-17-slim. I will look into updating this in the course as soon as possible. Once again, thank you for catching this!

Categories

Upcoming Training