Building Spring Boot 3.1.5 image using paketobuildpacks via maven plugin is not working

1.8k views Asked by At

I'm using Spring Boot 3.1.5, Java 21 and maven 3.9.5. I've got the following error when running mvn spring-boot:build-image

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder@sha256:17ea21162ba8c7717d3ead3ee3836a368aced7f02f2e59658e52029bd6d149e7'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run@sha256:1af9935d8987fd52b2266d288200c9482d1dd5529860bbf5bc2d248de1cb1a38'
[INFO]  > Executing lifecycle version v0.16.5
[INFO]  > Using build cache volume 'pack-cache-8847f704ad41.build'
[INFO] 
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Image with name "docker.io/library/elevate-insights:0.0.1-SNAPSHOT" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 26 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.6.3
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.2.6
[INFO]     [creator]     paketo-buildpacks/syft              1.32.1
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.7.4
[INFO]     [creator]     paketo-buildpacks/dist-zip          5.6.4
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.26.1
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.6.3
[INFO]     [creator]       https://github.com/paketo-buildpacks/ca-certificates
[INFO]     [creator]       Launch Helper: Contributing to layer
[INFO]     [creator]         Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for BellSoft Liberica 10.2.6
[INFO]     [creator]       https://github.com/paketo-buildpacks/bellsoft-liberica
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
[INFO]     [creator]         $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
[INFO]     [creator]         $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
[INFO]     [creator]         $BP_JVM_VERSION              21                                                           the Java version
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
[INFO]     [creator]         $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
[INFO]     [creator]         $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
[INFO]     [creator]         $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
[INFO]     [creator]         $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
[INFO]     [creator]         $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
[INFO]     [creator]         $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
[INFO]     [creator]         $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
[INFO]     [creator]         $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
[INFO]     [creator]         $BPL_JMX_PORT                5000                                                         configure the JMX port
[INFO]     [creator]         $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
[INFO]     [creator]         $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
[INFO]     [creator]         $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
[INFO]     [creator]         $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
[INFO]     [creator]         Using Java version 21 from BP_JVM_VERSION
[INFO]     [creator]       No valid JRE available, providing matching JDK instead. Using a JDK at runtime has security implications.
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to get dependency 
[INFO]     [creator]     unable to download 
[INFO]     [creator]     unable to request 
[INFO]     [creator]     Get "": unsupported protocol scheme ""
[INFO]     [creator]        : Contributing to layer
[INFO]     [creator]       Warning: Dependency has no SHA256. Skipping cache.
[INFO]     [creator]         Downloading from 
[INFO]     [creator]     ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.278 s
[INFO] Finished at: 2023-10-27T18:49:36+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image (default-cli) on project elevate-insights: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.1.5:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [Help 1]

Here's a snippet of my pom file:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

// omitted 

    <properties>
        <java.version>21</java.version>
    </properties>

// omitted

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                    <image>
                        <env>
                            <BP_JVM_VERSION>21</BP_JVM_VERSION>
                        </env>
                    </image>
                </configuration>
            </plugin>

N.B.: tried with Java 17 with no joy either

1

There are 1 answers

0
Daniel Mikusa On BEST ANSWER

You're using the old builder.

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder:base' 100%

The builder:base builder is for Ubuntu 18.04 Bionic. That has gone out of support with Ubuntu, so it has gone out of support with the Paketo project as well.

You need to use the latest builder, paketobuildpacks/builder-jammy-base, which has the latest buildpacks which have Java 21.

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <image>
                        <builder>paketobuildpacks/builder-jammy-base:latest</builder>
                    </image>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

This manual change will need to be made if you're using Spring Boot 3.1 or older. Starting in Spring Boot 3.2, it will use the Jammy builder by default.

An update from the Spring team:

Update November 23 2023: The Paketo team has announced that they will remove access to the Paketo Bionic builders in January 2024. To make this transition easier, Spring Boot has changed the default builder to the Paketo Jammy builder in the maintenance release for versions 2.7.18, 3.0.13, and 3.1.6.

See here for the original announcement: https://spring.io/blog/2023/09/22/paketo-buildpacks-bionic-end-of-support