Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlinks failing to resolve "no such file or directory" when running application container #450

Open
wleese opened this issue Dec 31, 2024 · 5 comments

Comments

@wleese
Copy link

wleese commented Dec 31, 2024

It would seem that symlinks cause issues when found in BOOT-INF

Expected Behavior

The Spring Boot application container resulting from calling creator should be runnable.

Current Behavior

In my test project here → https://github.com/wleese/demo-buildpacks, I'm unable to run the resulting container.

➜  ~/repos/tmp/demo-buildpacks git:(main) ✗ docker run  localhost:5443/demo-buildpacks:latest

unable to determine class count
unable to walk /app-repo
unable to open Jar /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar
open /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar: no such file or directory
ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1

➜  ~/repos/tmp/demo-buildpacks git:(main) ✗ docker run --entrypoint=/bin/bash -ti  localhost:5443/demo-buildpacks:latest

cnb@9a41c6f22b0f:/app-repo$ ls -lh /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar
lrwxrwxrwx 1 1001 cnb 91 Jan  1  1980 /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar -> /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings/spring-cloud-bindings-2.0.4.jar
cnb@9a41c6f22b0f:/app-repo$ ls -lh /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings/spring-cloud-bindings-2.0.4.jar
/usr/bin/ls: cannot access '/layers/paketo-buildpacks_spring-boot/spring-cloud-bindings/spring-cloud-bindings-2.0.4.jar': No such file or directory

I'm surprised I have the spring-cloud-bindings jar at all. I tried disabling it being contributed by a buildpack (see the env directory), didn't work. I double checked my dependencies, but I'm not pulling it in directly either.

Steps to Reproduce

In https://github.com/wleese/demo-buildpacks, run docker compose up, wait for the build process to succeed by looking at the logs of the demo-buildpacks container, then docker pull localhost:5443/demo-buildpacks:latest and docker run localhost:5443/demo-buildpacks:latest the resulting container.

@dmikusa
Copy link
Contributor

dmikusa commented Jan 3, 2025

This isn't an issue with symlink, at least not directly. What it's saying is that when your container starts there is something missing.

When the Spring Boot buildpack runs, it adds a layer with the Spring Cloud Bindings JAR and then symlinks that file in the layer to your app files, so your app can use it. When your app container is being run, it should have that layer present, so the symlink should resolve. In this case, the layer is not there and you're getting the error.

It's hard to say why it's not there with the given information. I'm definitely curious as you shouldn't see issues like this normally, if you could include the full output from building the application that would be helpful.

Otherwise, you mentioned not being sure why that was there. If you don't need it, you can set BP_SPRING_CLOUD_BINDINGS_DISABLED=true and the Spring Boot buildpack won't add it. It sounds like that would probably work around this issue.

The other option, if you do need it is to include the JAR file yourself (i.e in your maven or gradle config). If the buildpack sees it exists, then it won't add it a second time. That would probably also work around this issue.

@dmikusa dmikusa changed the title Symlinks not supported in Java Memory Calculator? Symlinks failing to resolve "no such file or directory" when running application container Jan 3, 2025
@wleese
Copy link
Author

wleese commented Jan 3, 2025

Thanks for explaining.

I actually set BP_SPRING_CLOUD_BINDINGS_DISABLED=true as far as I can tell: https://github.com/wleese/demo-buildpacks/blob/main/env/BP_SPRING_CLOUD_BINDINGS_DISABLED

Here's the build output:

demo-buildpacks-1  | Updating certificates in /etc/ssl/certs...
demo-buildpacks-1  | rehash: warning: skipping ca-certificates.crt,it does not contain exactly one certificate or CRL
demo-buildpacks-1  | 1 added, 0 removed; done.
demo-buildpacks-1  | Running hooks in /etc/ca-certificates/update.d...
demo-buildpacks-1  | done.
demo-buildpacks-1  | Warning: No cached data will be used, no cache specified.
demo-buildpacks-1  | ===> ANALYZING
demo-buildpacks-1  | Restoring data for SBOM from previous image
demo-buildpacks-1  | ===> DETECTING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  | 10 of 26 buildpacks participating
demo-buildpacks-1  | paketo-buildpacks/ca-certificates   3.9.0
demo-buildpacks-1  | paketo-buildpacks/bellsoft-liberica 11.0.1
demo-buildpacks-1  | paketo-buildpacks/syft              2.6.1
demo-buildpacks-1  | paketo-buildpacks/maven             6.19.2
demo-buildpacks-1  | paketo-buildpacks/executable-jar    6.12.0
demo-buildpacks-1  | paketo-buildpacks/apache-tomcat     8.4.1
demo-buildpacks-1  | paketo-buildpacks/apache-tomee      1.11.0
demo-buildpacks-1  | paketo-buildpacks/liberty           4.4.1
demo-buildpacks-1  | paketo-buildpacks/dist-zip          5.9.0
demo-buildpacks-1  | paketo-buildpacks/spring-boot       5.32.0
demo-buildpacks-1  | ===> RESTORING
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image
demo-buildpacks-1  | ===> BUILDING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for CA Certificates 3.9.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/ca-certificates
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_EMBED_CERTS                    false  Embed certificates into the image
demo-buildpacks-1  |     $BP_ENABLE_RUNTIME_CERT_BINDING    true   Deprecated: Enable/disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |     $BP_RUNTIME_CERT_BINDING_DISABLED  false  Disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for BellSoft Liberica 11.0.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/bellsoft-liberica
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
demo-buildpacks-1  |     $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
demo-buildpacks-1  |     $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
demo-buildpacks-1  |     $BP_JVM_VERSION              21
demo-buildpacks-1  |                                                               the Java version
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
demo-buildpacks-1  |     $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
demo-buildpacks-1  |     $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
demo-buildpacks-1  |     $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
demo-buildpacks-1  |     $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
demo-buildpacks-1  |     $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
demo-buildpacks-1  |     $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
demo-buildpacks-1  |     $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
demo-buildpacks-1  |     $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
demo-buildpacks-1  |     $BPL_JMX_PORT                5000                                                         configure the JMX port
demo-buildpacks-1  |     $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
demo-buildpacks-1  |     $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
demo-buildpacks-1  |     $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
demo-buildpacks-1  |     $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
demo-buildpacks-1  |     Using Java version 21
demo-buildpacks-1  |      from BP_JVM_VERSION
demo-buildpacks-1  |   BellSoft Liberica JDK 21.0.5: Contributing to layer
demo-buildpacks-1  |     Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.5+11/bellsoft-jdk21.0.5+11-linux-amd64.tar.gz
demo-buildpacks-1  |     Verifying checksum
demo-buildpacks-1  |     Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jdk
demo-buildpacks-1  |     Adding 147 container CA certificates to JVM truststore
demo-buildpacks-1  |     Writing env.build/JAVA_HOME.override
demo-buildpacks-1  |     Writing env.build/JDK_HOME.override
demo-buildpacks-1  |   BellSoft Liberica JRE 21.0.5: Reusing cached layer
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |   Java Security Properties: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Syft 2.6.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/syft
demo-buildpacks-1  |     Downloading from https://github.com/anchore/syft/releases/download/v1.18.1/syft_1.18.1_linux_amd64.tar.gz
demo-buildpacks-1  |     Verifying checksum
demo-buildpacks-1  |     Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Maven 6.19.2
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/maven
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_EXCLUDE_FILES                                                                            colon separated list of glob patterns, matched source files are removed
demo-buildpacks-1  |     $BP_INCLUDE_FILES                                                                            colon separated list of glob patterns, matched source files are included
demo-buildpacks-1  |     $BP_JAVA_INSTALL_NODE                 false                                                  whether to install Yarn/Node binaries based on the presence of a package.json or yarn.lock file
demo-buildpacks-1  |     $BP_MAVEN_ACTIVE_PROFILES                                                                    the active profiles (comma separated: such as: p1,!p2,?p3) to pass to Maven
demo-buildpacks-1  |     $BP_MAVEN_ADDITIONAL_BUILD_ARGUMENTS  --log-file ./mvn.log
demo-buildpacks-1  |                                       the additionnal arguments (appended to BP_MAVEN_BUILD_ARGUMENTS) to pass to Maven
demo-buildpacks-1  |     $BP_MAVEN_BUILD_ARGUMENTS             -Dmaven.test.skip=true --no-transfer-progress package  the arguments to pass to Maven
demo-buildpacks-1  |     $BP_MAVEN_BUILT_ARTIFACT              target/*.[ejw]ar                                       the built application artifact explicitly.  Supersedes $BP_MAVEN_BUILT_MODULE
demo-buildpacks-1  |     $BP_MAVEN_BUILT_MODULE                                                                       the module to find application artifact in
demo-buildpacks-1  |     $BP_MAVEN_DAEMON_ENABLED              false                                                  use maven daemon
demo-buildpacks-1  |     $BP_MAVEN_POM_FILE                    pom.xml                                                the location of the main pom.xml file, relative to the application root
demo-buildpacks-1  |     $BP_MAVEN_SETTINGS_PATH                                                                      the path to a Maven settings file
demo-buildpacks-1  |     $BP_MAVEN_VERSION                     3                                                      the Maven version
demo-buildpacks-1  |     $BP_NODE_PROJECT_PATH                                                                        configure a project subdirectory to look for `package.json` and `yarn.lock` files
demo-buildpacks-1  |     Creating cache directory /home/cnb/.m2
demo-buildpacks-1  |   Compiled Application: Contributing to layer
demo-buildpacks-1  |     Executing mvnw --batch-mode -Dmaven.test.skip=true --no-transfer-progress package --log-file ./mvn.log
demo-buildpacks-1  |
demo-buildpacks-1  |   Removing source code
demo-buildpacks-1  |   Restoring application artifact
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Executable JAR 6.12.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/executable-jar
demo-buildpacks-1  |   Class Path: Contributing to layer
demo-buildpacks-1  |     Writing env/CLASSPATH.delim
demo-buildpacks-1  |     Writing env/CLASSPATH.prepend
demo-buildpacks-1  |   Process types:
demo-buildpacks-1  |     executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     task:           java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     web:            java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  | SKIPPED: `Main-Class` found in `META-INF/MANIFEST.MF`, skipping build
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Spring Boot 5.32.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/spring-boot
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BPL_JVM_CDS_ENABLED                 false   whether to enable CDS optimizations at runtime
demo-buildpacks-1  |     $BPL_SPRING_AOT_ENABLED              false   whether to enable Spring AOT at runtime
demo-buildpacks-1  |     $BP_JVM_CDS_ENABLED                  false   whether to enable CDS & perform JVM training run
demo-buildpacks-1  |     $BP_SPRING_AOT_ENABLED               false   whether to enable Spring AOT
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_DISABLED   true
demo-buildpacks-1  |        whether to contribute Spring Boot cloud bindings support
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_VERSION    1       default version of Spring Cloud Bindings library to contribute
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false
demo-buildpacks-1  |       whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true    Deprecated - whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |   Creating slices from layers index
demo-buildpacks-1  |     dependencies (10.1 MB)
demo-buildpacks-1  |     spring-boot-loader (458.8 KB)
demo-buildpacks-1  |     snapshot-dependencies (0.0 B)
demo-buildpacks-1  |     application (48.1 KB)
demo-buildpacks-1  |   Spring Cloud Bindings 2.0.4: Contributing to layer
demo-buildpacks-1  |     Downloading from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-bindings/2.0.4/spring-cloud-bindings-2.0.4.jar
demo-buildpacks-1  |     Verifying checksum
demo-buildpacks-1  |     Copying to /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings
demo-buildpacks-1  |   Web Application Type: Contributing to layer
demo-buildpacks-1  |     Non-web application detected
demo-buildpacks-1  |     Writing env.launch/BPL_JVM_THREAD_COUNT.default
demo-buildpacks-1  |   Launch Helper: Contributing to layer
demo-buildpacks-1  |     Creating /layers/paketo-buildpacks_spring-boot/helper/exec.d/spring-cloud-bindings
demo-buildpacks-1  |   4 application slices
demo-buildpacks-1  |   Image labels:
demo-buildpacks-1  |     org.opencontainers.image.title
demo-buildpacks-1  |     org.opencontainers.image.version
demo-buildpacks-1  |     org.springframework.boot.version
demo-buildpacks-1  | ===> EXPORTING
demo-buildpacks-1  | Reusing layers from image 'docker-registry:443/demo-buildpacks@sha256:76471a5849e002c224bd78cee867f81ea445b053fe6a5fec0aa047b649f562fc'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/ca-certificates:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:jre'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/executable-jar:classpath'
demo-buildpacks-1  | Adding layer 'paketo-buildpacks/spring-boot:helper'
demo-buildpacks-1  | Adding layer 'paketo-buildpacks/spring-boot:spring-cloud-bindings'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/spring-boot:web-application-type'
demo-buildpacks-1  | Adding layer 'buildpacksio/lifecycle:launch.sbom'
demo-buildpacks-1  | Reused 5/5 app layer(s)
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:launcher'
demo-buildpacks-1  | Adding layer 'buildpacksio/lifecycle:config'
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:process-types'
demo-buildpacks-1  | Adding label 'io.buildpacks.lifecycle.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.build.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.project.metadata'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.title'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.version'
demo-buildpacks-1  | Adding label 'org.springframework.boot.version'
demo-buildpacks-1  | Setting default process type 'web'
demo-buildpacks-1  | Saving docker-registry:443/demo-buildpacks:latest...
demo-buildpacks-1  | *** Images (sha256:d159a2df9d040530dffad952c1aef67e367999eab7efd3a2172c3cb15c167608):
demo-buildpacks-1  |       docker-registry:443/demo-buildpacks:latest
demo-buildpacks-1  | Updating certificates in /etc/ssl/certs...
demo-buildpacks-1  | 0 added, 0 removed; done.
demo-buildpacks-1  | Running hooks in /etc/ca-certificates/update.d...
demo-buildpacks-1  | done.
demo-buildpacks-1  | Warning: No cached data will be used, no cache specified.
demo-buildpacks-1  | ===> ANALYZING
demo-buildpacks-1  | Restoring data for SBOM from previous image
demo-buildpacks-1  | ===> DETECTING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  | 6 of 26 buildpacks participating
demo-buildpacks-1  | paketo-buildpacks/ca-certificates   3.9.0
demo-buildpacks-1  | paketo-buildpacks/bellsoft-liberica 11.0.1
demo-buildpacks-1  | paketo-buildpacks/syft              2.6.1
demo-buildpacks-1  | paketo-buildpacks/executable-jar    6.12.0
demo-buildpacks-1  | paketo-buildpacks/dist-zip          5.9.0
demo-buildpacks-1  | paketo-buildpacks/spring-boot       5.32.0
demo-buildpacks-1  | ===> RESTORING
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/spring-boot:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image
demo-buildpacks-1  | ===> BUILDING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for CA Certificates 3.9.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/ca-certificates
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_EMBED_CERTS                    false  Embed certificates into the image
demo-buildpacks-1  |     $BP_ENABLE_RUNTIME_CERT_BINDING    true   Deprecated: Enable/disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |     $BP_RUNTIME_CERT_BINDING_DISABLED  false  Disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for BellSoft Liberica 11.0.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/bellsoft-liberica
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
demo-buildpacks-1  |     $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
demo-buildpacks-1  |     $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
demo-buildpacks-1  |     $BP_JVM_VERSION              21
demo-buildpacks-1  |                                                               the Java version
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
demo-buildpacks-1  |     $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
demo-buildpacks-1  |     $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
demo-buildpacks-1  |     $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
demo-buildpacks-1  |     $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
demo-buildpacks-1  |     $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
demo-buildpacks-1  |     $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
demo-buildpacks-1  |     $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
demo-buildpacks-1  |     $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
demo-buildpacks-1  |     $BPL_JMX_PORT                5000                                                         configure the JMX port
demo-buildpacks-1  |     $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
demo-buildpacks-1  |     $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
demo-buildpacks-1  |     $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
demo-buildpacks-1  |     $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
demo-buildpacks-1  |     Using Java version 21
demo-buildpacks-1  |      from BP_JVM_VERSION
demo-buildpacks-1  |   BellSoft Liberica JRE 21.0.5: Reusing cached layer
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |   Java Security Properties: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Syft 2.6.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/syft
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Executable JAR 6.12.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/executable-jar
demo-buildpacks-1  |   Class Path: Reusing cached layer
demo-buildpacks-1  |   Process types:
demo-buildpacks-1  |     executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     task:           java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     web:            java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Spring Boot 5.32.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/spring-boot
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BPL_JVM_CDS_ENABLED                 false   whether to enable CDS optimizations at runtime
demo-buildpacks-1  |     $BPL_SPRING_AOT_ENABLED              false   whether to enable Spring AOT at runtime
demo-buildpacks-1  |     $BP_JVM_CDS_ENABLED                  false   whether to enable CDS & perform JVM training run
demo-buildpacks-1  |     $BP_SPRING_AOT_ENABLED               false   whether to enable Spring AOT
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_DISABLED   true
demo-buildpacks-1  |        whether to contribute Spring Boot cloud bindings support
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_VERSION    1       default version of Spring Cloud Bindings library to contribute
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false
demo-buildpacks-1  |       whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true    Deprecated - whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |   A Spring Cloud Bindings library was found in the Spring Boot libs - not adding another one
demo-buildpacks-1  |   Creating slices from layers index
demo-buildpacks-1  |     dependencies (10.1 MB)
demo-buildpacks-1  |     spring-boot-loader (458.8 KB)
demo-buildpacks-1  |     snapshot-dependencies (0.0 B)
demo-buildpacks-1  |     application (48.1 KB)
demo-buildpacks-1  |   Web Application Type: Contributing to layer
demo-buildpacks-1  |     Non-web application detected
demo-buildpacks-1  |     Writing env.launch/BPL_JVM_THREAD_COUNT.default
demo-buildpacks-1  |   4 application slices
demo-buildpacks-1  |   Image labels:
demo-buildpacks-1  |     org.opencontainers.image.title
demo-buildpacks-1  |     org.opencontainers.image.version
demo-buildpacks-1  |     org.springframework.boot.version
demo-buildpacks-1  | ===> EXPORTING
demo-buildpacks-1  | Reusing layers from image 'docker-registry:443/demo-buildpacks@sha256:d159a2df9d040530dffad952c1aef67e367999eab7efd3a2172c3cb15c167608'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/ca-certificates:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:jre'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/executable-jar:classpath'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/spring-boot:web-application-type'
demo-buildpacks-1  | Adding layer 'buildpacksio/lifecycle:launch.sbom'
demo-buildpacks-1  | Reused 4/5 app layer(s)
demo-buildpacks-1  | Added 1/5 app layer(s)
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:launcher'
demo-buildpacks-1  | Adding layer 'buildpacksio/lifecycle:config'
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:process-types'
demo-buildpacks-1  | Adding label 'io.buildpacks.lifecycle.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.build.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.project.metadata'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.title'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.version'
demo-buildpacks-1  | Adding label 'org.springframework.boot.version'
demo-buildpacks-1  | Setting default process type 'web'
demo-buildpacks-1  | Saving docker-registry:443/demo-buildpacks:latest...
demo-buildpacks-1  | *** Images (sha256:5fe22e94ced5c26494ef899ee90ae700d1f61e520721ebdbe76d68b8d27e12ab):
demo-buildpacks-1  |       docker-registry:443/demo-buildpacks:latest
demo-buildpacks-1  | Updating certificates in /etc/ssl/certs...
demo-buildpacks-1  | 0 added, 0 removed; done.
demo-buildpacks-1  | Running hooks in /etc/ca-certificates/update.d...
demo-buildpacks-1  | done.
demo-buildpacks-1  | Warning: No cached data will be used, no cache specified.
demo-buildpacks-1  | ===> ANALYZING
demo-buildpacks-1  | Restoring data for SBOM from previous image
demo-buildpacks-1  | ===> DETECTING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  | 6 of 26 buildpacks participating
demo-buildpacks-1  | paketo-buildpacks/ca-certificates   3.9.0
demo-buildpacks-1  | paketo-buildpacks/bellsoft-liberica 11.0.1
demo-buildpacks-1  | paketo-buildpacks/syft              2.6.1
demo-buildpacks-1  | paketo-buildpacks/executable-jar    6.12.0
demo-buildpacks-1  | paketo-buildpacks/dist-zip          5.9.0
demo-buildpacks-1  | paketo-buildpacks/spring-boot       5.32.0
demo-buildpacks-1  | ===> RESTORING
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
demo-buildpacks-1  | Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image
demo-buildpacks-1  | ===> BUILDING
demo-buildpacks-1  | target distro name/version labels not found, reading /etc/os-release file
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for CA Certificates 3.9.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/ca-certificates
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_EMBED_CERTS                    false  Embed certificates into the image
demo-buildpacks-1  |     $BP_ENABLE_RUNTIME_CERT_BINDING    true   Deprecated: Enable/disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |     $BP_RUNTIME_CERT_BINDING_DISABLED  false  Disable certificate helper layer to add certs at runtime
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for BellSoft Liberica 11.0.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/bellsoft-liberica
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
demo-buildpacks-1  |     $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
demo-buildpacks-1  |     $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
demo-buildpacks-1  |     $BP_JVM_VERSION              21
demo-buildpacks-1  |                                                               the Java version
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
demo-buildpacks-1  |     $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
demo-buildpacks-1  |     $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
demo-buildpacks-1  |     $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
demo-buildpacks-1  |     $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
demo-buildpacks-1  |     $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
demo-buildpacks-1  |     $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
demo-buildpacks-1  |     $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
demo-buildpacks-1  |     $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
demo-buildpacks-1  |     $BPL_JMX_PORT                5000                                                         configure the JMX port
demo-buildpacks-1  |     $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
demo-buildpacks-1  |     $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
demo-buildpacks-1  |     $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
demo-buildpacks-1  |     $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
demo-buildpacks-1  |     Using Java version 21
demo-buildpacks-1  |      from BP_JVM_VERSION
demo-buildpacks-1  |   BellSoft Liberica JRE 21.0.5: Reusing cached layer
demo-buildpacks-1  |   Launch Helper: Reusing cached layer
demo-buildpacks-1  |   Java Security Properties: Reusing cached layer
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Syft 2.6.1
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/syft
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Executable JAR 6.12.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/executable-jar
demo-buildpacks-1  |   Class Path: Reusing cached layer
demo-buildpacks-1  |   Process types:
demo-buildpacks-1  |     executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     task:           java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |     web:            java org.springframework.boot.loader.launch.JarLauncher (direct)
demo-buildpacks-1  |
demo-buildpacks-1  | Paketo Buildpack for Spring Boot 5.32.0
demo-buildpacks-1  |   https://github.com/paketo-buildpacks/spring-boot
demo-buildpacks-1  |   Build Configuration:
demo-buildpacks-1  |     $BPL_JVM_CDS_ENABLED                 false   whether to enable CDS optimizations at runtime
demo-buildpacks-1  |     $BPL_SPRING_AOT_ENABLED              false   whether to enable Spring AOT at runtime
demo-buildpacks-1  |     $BP_JVM_CDS_ENABLED                  false   whether to enable CDS & perform JVM training run
demo-buildpacks-1  |     $BP_SPRING_AOT_ENABLED               false   whether to enable Spring AOT
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_DISABLED   true
demo-buildpacks-1  |        whether to contribute Spring Boot cloud bindings support
demo-buildpacks-1  |     $BP_SPRING_CLOUD_BINDINGS_VERSION    1       default version of Spring Cloud Bindings library to contribute
demo-buildpacks-1  |   Launch Configuration:
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false
demo-buildpacks-1  |       whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |     $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true    Deprecated - whether to auto-configure Spring Boot environment properties from bindings
demo-buildpacks-1  |   A Spring Cloud Bindings library was found in the Spring Boot libs - not adding another one
demo-buildpacks-1  |   Creating slices from layers index
demo-buildpacks-1  |     dependencies (10.1 MB)
demo-buildpacks-1  |     spring-boot-loader (458.8 KB)
demo-buildpacks-1  |     snapshot-dependencies (0.0 B)
demo-buildpacks-1  |     application (48.1 KB)
demo-buildpacks-1  |   Web Application Type: Reusing cached layer
demo-buildpacks-1  |   4 application slices
demo-buildpacks-1  |   Image labels:
demo-buildpacks-1  |     org.opencontainers.image.title
demo-buildpacks-1  |     org.opencontainers.image.version
demo-buildpacks-1  |     org.springframework.boot.version
demo-buildpacks-1  | ===> EXPORTING
demo-buildpacks-1  | Reusing layers from image 'docker-registry:443/demo-buildpacks@sha256:5fe22e94ced5c26494ef899ee90ae700d1f61e520721ebdbe76d68b8d27e12ab'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/ca-certificates:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:helper'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/bellsoft-liberica:jre'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/executable-jar:classpath'
demo-buildpacks-1  | Reusing layer 'paketo-buildpacks/spring-boot:web-application-type'
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:launch.sbom'
demo-buildpacks-1  | Reused 5/5 app layer(s)
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:launcher'
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:config'
demo-buildpacks-1  | Reusing layer 'buildpacksio/lifecycle:process-types'
demo-buildpacks-1  | Adding label 'io.buildpacks.lifecycle.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.build.metadata'
demo-buildpacks-1  | Adding label 'io.buildpacks.project.metadata'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.title'
demo-buildpacks-1  | Adding label 'org.opencontainers.image.version'
demo-buildpacks-1  | Adding label 'org.springframework.boot.version'
demo-buildpacks-1  | Setting default process type 'web'
demo-buildpacks-1  | Saving docker-registry:443/demo-buildpacks:latest...
demo-buildpacks-1  | *** Images (sha256:5fe22e94ced5c26494ef899ee90ae700d1f61e520721ebdbe76d68b8d27e12ab):
demo-buildpacks-1  |       docker-registry:443/demo-buildpacks:latest

@dmikusa
Copy link
Contributor

dmikusa commented Jan 13, 2025

demo-buildpacks-1 | $BP_SPRING_CLOUD_BINDINGS_DISABLED true
demo-buildpacks-1 | whether to contribute Spring Boot cloud bindings support

This is very interesting. It's telling us that you have set this and it's picked up your setting, so this should disable contributing the cloud bindings. It should have the same effect as it seeing that you've already put the library into the classpath, see code here.

Something clearly isn't working though because further down you can see that it's contributing the JAR and also the helper, which should be skipped.

demo-buildpacks-1  |   Spring Cloud Bindings 2.0.4: Contributing to layer
demo-buildpacks-1  |     Downloading from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-bindings/2.0.4/spring-cloud-bindings-2.0.4.jar
demo-buildpacks-1  |     Verifying checksum
demo-buildpacks-1  |     Copying to /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings
demo-buildpacks-1  |   Web Application Type: Contributing to layer
demo-buildpacks-1  |     Non-web application detected
demo-buildpacks-1  |     Writing env.launch/BPL_JVM_THREAD_COUNT.default
demo-buildpacks-1  |   Launch Helper: Contributing to layer
demo-buildpacks-1  |     Creating /layers/paketo-buildpacks_spring-boot/helper/exec.d/spring-cloud-bindings
demo-buildpacks-1  |   4 application slices

The only thing that comes to mind is strconv.ParseBool(s) is failing for some reason. When it fails, we don't return an error we just evaluate to false. It will fail if you have white space on the end of the string.

See https://go.dev/play/p/rUoxpAUwD7_6. For example true or true\n will not evaluate to true, they'll be false. So it might be that the display works because the string looks like true but that there's an extra character throwing off the parser.

@wleese
Copy link
Author

wleese commented Jan 14, 2025

@dmikusa .. in the end, maybe I just shot myself in the foot accidentally. I made this change and it works now: wleese/demo-buildpacks@6c5d509

Note that I still think that if the bindings are enabled that this error:

unable to open Jar /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar
open /app-repo/BOOT-INF/lib/spring-cloud-bindings-2.0.4.jar: no such file or directory
ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1

.. doesn't make sense to this particular user :)

@dmikusa
Copy link
Contributor

dmikusa commented Jan 14, 2025

The memory calculator will go through your JARs and count classes as part of determining how much metaspace your app needs.

The JAR it's failing on is a symlink to the actual JAR file in a different layer of the image. That layer is not present for some reason. If you run dive <img> on the image produced by your build, you can look through the individual layers. You should see a layer for /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings, but I bet that is not present.

Normally, when you run pack build. It's going to make a copy of your app files in a container and do the build there. You're not using pack build, so making that clean copy of your app files is up to you. It's important to make a clean copy before every build because the buildpacks can and will modify the contents of your application. It might be that there is some state left over from a previous build here (i.e. the symlink in /app-repo is still there from a previous build). This would make some sense given what you've explained because you're setting BP_SPRING_CLOUD_BINDINGS_DISABLED to true which tells the buildpack to not add the actual JAR, so that layer won't exist. If the symlink still exists, it would cause the issue you're seeing.

Aside from that, I'm not sure. I haven't seen any reports from users that build with pack build or Spring Boot build tools about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants