paketo-buildpacks / samples

A collection of samples
Apache License 2.0
150 stars 113 forks source link

`java/java-node/gradle-node` sample broken with JVM 21 #873

Open lmarchione-r7 opened 5 days ago

lmarchione-r7 commented 5 days ago

Expected Behavior

The java/java-node/gradle-node sample should build out of the box.

Current Behavior

The release of paketo-buildpacks/bellsoft-liberica:v11.0.0 includes an upgrade of BP_JVM_VERSION from 17 to 21. This breaks the java/java-node/gradle-node sample.

Possible Solution

I'm not sure why the change to JVM 21 would break this sample.

Steps to Reproduce

########################################
# download samples
########################################
git clone https://github.com/paketo-buildpacks/samples.git
cd samples

########################################
# broken (bellsoft v11.0.0 with default JVM 21)
########################################
export SAMPLE=samples-java-gradle-node
pack build --clear-cache ${SAMPLE} --path java/java-node/gradle-node --pull-policy if-not-present \
    --builder paketobuildpacks/builder-jammy-buildpackless-base:latest \
    --buildpack gcr.io/paketo-buildpacks/ca-certificates:3.8.6 \
    --buildpack gcr.io/paketo-buildpacks/bellsoft-liberica:11.0.0 \
    --buildpack gcr.io/paketo-buildpacks/node-engine:4.1.15 \
    --buildpack gcr.io/paketo-buildpacks/syft:2.4.0 \
    --buildpack gcr.io/paketo-buildpacks/gradle:7.14.1 \
    --buildpack gcr.io/paketo-buildpacks/executable-jar:6.11.3 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomcat:8.2.2 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomee:1.10.4 \
    --buildpack gcr.io/paketo-buildpacks/liberty:4.3.1 \
    --buildpack gcr.io/paketo-buildpacks/dist-zip:5.8.5 \
    --buildpack gcr.io/paketo-buildpacks/spring-boot:5.31.2 \
    --env BP_JAVA_INSTALL_NODE=true \
    --env BP_NODE_PROJECT_PATH=frontend

########################################
# working (bellsoft v11.0.0 with JVM 17)
########################################
export SAMPLE=samples-java-gradle-node
pack build --clear-cache ${SAMPLE} --path java/java-node/gradle-node --pull-policy if-not-present \
    --builder paketobuildpacks/builder-jammy-buildpackless-base:latest \
    --buildpack gcr.io/paketo-buildpacks/ca-certificates:3.8.6 \
    --buildpack gcr.io/paketo-buildpacks/bellsoft-liberica:11.0.0 \
    --buildpack gcr.io/paketo-buildpacks/node-engine:4.1.15 \
    --buildpack gcr.io/paketo-buildpacks/syft:2.4.0 \
    --buildpack gcr.io/paketo-buildpacks/gradle:7.14.1 \
    --buildpack gcr.io/paketo-buildpacks/executable-jar:6.11.3 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomcat:8.2.2 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomee:1.10.4 \
    --buildpack gcr.io/paketo-buildpacks/liberty:4.3.1 \
    --buildpack gcr.io/paketo-buildpacks/dist-zip:5.8.5 \
    --buildpack gcr.io/paketo-buildpacks/spring-boot:5.31.2 \
    --env BP_JAVA_INSTALL_NODE=true \
    --env BP_NODE_PROJECT_PATH=frontend \
    --env BP_JVM_VERSION=17

########################################
# working (because bellsoft v10.9.1 uses JVM 17)
########################################
export SAMPLE=samples-java-gradle-node
pack build --clear-cache ${SAMPLE} --path java/java-node/gradle-node --pull-policy if-not-present \
    --builder paketobuildpacks/builder-jammy-buildpackless-base:latest \
    --buildpack gcr.io/paketo-buildpacks/ca-certificates:3.8.6 \
    --buildpack gcr.io/paketo-buildpacks/bellsoft-liberica:10.9.1 \
    --buildpack gcr.io/paketo-buildpacks/node-engine:4.1.15 \
    --buildpack gcr.io/paketo-buildpacks/syft:2.4.0 \
    --buildpack gcr.io/paketo-buildpacks/gradle:7.14.1 \
    --buildpack gcr.io/paketo-buildpacks/executable-jar:6.11.3 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomcat:8.2.2 \
    --buildpack gcr.io/paketo-buildpacks/apache-tomee:1.10.4 \
    --buildpack gcr.io/paketo-buildpacks/liberty:4.3.1 \
    --buildpack gcr.io/paketo-buildpacks/dist-zip:5.8.5 \
    --buildpack gcr.io/paketo-buildpacks/spring-boot:5.31.2 \
    --env BP_JAVA_INSTALL_NODE=true \
    --env BP_NODE_PROJECT_PATH=frontend

See below for the error when using bellsoft v11.0.0 with default JVM 21.

Warning: Builder is trusted but additional modules were added; using the untrusted (5 phases) build flow
===> ANALYZING
===> DETECTING
[detector] target distro name/version labels not found, reading /etc/os-release file
[detector] paketo-buildpacks/ca-certificates   3.8.6
[detector] paketo-buildpacks/bellsoft-liberica 11.0.0
[detector] paketo-buildpacks/node-engine       4.1.15
[detector] paketo-buildpacks/syft              2.4.0
[detector] paketo-buildpacks/gradle            7.14.1
[detector] paketo-buildpacks/executable-jar    6.11.3
[detector] paketo-buildpacks/apache-tomcat     8.2.2
[detector] paketo-buildpacks/apache-tomee      1.10.4
[detector] paketo-buildpacks/liberty           4.3.1
[detector] paketo-buildpacks/dist-zip          5.8.5
[detector] paketo-buildpacks/spring-boot       5.31.2
===> RESTORING
[restorer] Skipping buildpack layer analysis
===> BUILDING
[builder] target distro name/version labels not found, reading /etc/os-release file
[builder]
[builder] Paketo Buildpack for CA Certificates 3.8.6
[builder]   https://github.com/paketo-buildpacks/ca-certificates
[builder]   Build Configuration:
[builder]     $BP_EMBED_CERTS                    false  Embed certificates into the image
[builder]     $BP_ENABLE_RUNTIME_CERT_BINDING    true   Deprecated: Enable/disable certificate helper layer to add certs at runtime
[builder]     $BP_RUNTIME_CERT_BINDING_DISABLED  false  Disable certificate helper layer to add certs at runtime
[builder]   Launch Helper: Contributing to layer
[builder]     Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[builder]
[builder] Paketo Buildpack for BellSoft Liberica 11.0.0
[builder]   https://github.com/paketo-buildpacks/bellsoft-liberica
[builder]   Build Configuration:
[builder]     $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
[builder]     $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
[builder]     $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
[builder]     $BP_JVM_VERSION              21                                                           the Java version
[builder]   Launch Configuration:
[builder]     $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
[builder]     $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
[builder]     $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
[builder]     $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
[builder]     $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
[builder]     $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
[builder]     $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
[builder]     $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
[builder]     $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
[builder]     $BPL_JMX_PORT                5000                                                         configure the JMX port
[builder]     $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
[builder]     $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
[builder]     $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
[builder]     $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
[builder]     Using buildpack default Java version 21
[builder]   BellSoft Liberica JDK 21.0.5: Contributing to layer
[builder]     Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.5+11/bellsoft-jdk21.0.5+11-linux-amd64.tar.gz
[builder]     Verifying checksum
[builder]     Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jdk
[builder]     Adding 146 container CA certificates to JVM truststore
[builder]     Writing env.build/JAVA_HOME.override
[builder]     Writing env.build/JDK_HOME.override
[builder]   BellSoft Liberica JRE 21.0.5: Contributing to layer
[builder]     Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.5+11/bellsoft-jre21.0.5+11-linux-amd64.tar.gz
[builder]     Verifying checksum
[builder]     Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
[builder]     Adding 146 container CA certificates to JVM truststore
[builder]     Writing env.launch/BPI_APPLICATION_PATH.default
[builder]     Writing env.launch/BPI_JVM_CACERTS.default
[builder]     Writing env.launch/BPI_JVM_CLASS_COUNT.default
[builder]     Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
[builder]     Writing env.launch/JAVA_HOME.default
[builder]     Writing env.launch/JAVA_TOOL_OPTIONS.append
[builder]     Writing env.launch/JAVA_TOOL_OPTIONS.delim
[builder]     Writing env.launch/MALLOC_ARENA_MAX.default
[builder]   Launch Helper: Contributing to layer
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jvm-heap
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jmx
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jfr
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/debug-9
[builder]     Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/nmt
[builder]   Java Security Properties: Contributing to layer
[builder]     Writing env.launch/JAVA_SECURITY_PROPERTIES.default
[builder]     Writing env.launch/JAVA_TOOL_OPTIONS.append
[builder]     Writing env.launch/JAVA_TOOL_OPTIONS.delim
[builder] Paketo Buildpack for Node Engine 4.1.15
[builder]   Resolving Node Engine version
[builder]     Candidate version sources (in priority order):
[builder]       <unknown> -> ""
[builder]
[builder]     Selected Node Engine version (using <unknown>): 20.15.0
[builder]
[builder]   Executing build process
[builder]     Installing Node Engine 20.15.0
[builder]       Completed in 4.509s
[builder]
[builder]   Generating SBOM for /layers/paketo-buildpacks_node-engine/node
[builder]       Completed in 1ms
[builder]
[builder]   Configuring build environment
[builder]     NODE_ENV     -> "production"
[builder]     NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
[builder]     NODE_OPTIONS -> "--use-openssl-ca"
[builder]     NODE_VERBOSE -> "false"
[builder]
[builder]   Configuring launch environment
[builder]     NODE_ENV     -> "production"
[builder]     NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
[builder]     NODE_OPTIONS -> "--use-openssl-ca"
[builder]     NODE_VERBOSE -> "false"
[builder]
[builder]     Writing exec.d/0-optimize-memory
[builder]       Calculates available memory based on container limits at launch time.
[builder]       Made available in the MEMORY_AVAILABLE environment variable.
[builder]     Writing exec.d/1-inspector
[builder]
[builder]
[builder] Paketo Buildpack for Syft 2.4.0
[builder]   https://github.com/paketo-buildpacks/syft
[builder]     Downloading from https://github.com/anchore/syft/releases/download/v1.15.0/syft_1.15.0_linux_amd64.tar.gz
[builder]     Verifying checksum
[builder]     Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
[builder]
[builder] Paketo Buildpack for Gradle 7.14.1
[builder]   https://github.com/paketo-buildpacks/gradle
[builder]   Build Configuration:
[builder]     $BP_EXCLUDE_FILES                                                                       colon separated list of glob patterns, matched source files are removed
[builder]     $BP_GRADLE_ADDITIONAL_BUILD_ARGUMENTS                                                   the additionnal arguments (appended to BP_GRADLE_BUILD_ARGUMENTS) to pass to Gradle
[builder]     $BP_GRADLE_BUILD_ARGUMENTS             --no-daemon -Dorg.gradle.welcome=never assemble  the arguments to pass to Gradle
[builder]     $BP_GRADLE_BUILD_FILE                                                                   the location of the main build config file, relative to the application root
[builder]     $BP_GRADLE_BUILT_ARTIFACT              build/libs/*.[jw]ar                              the built application artifact explicitly.  Supersedes $BP_GRADLE_BUILT_MODULE
[builder]     $BP_GRADLE_BUILT_MODULE                                                                 the module to find application artifact in
[builder]     $BP_GRADLE_INIT_SCRIPT_PATH                                                             the path to a Gradle init script file
[builder]     $BP_INCLUDE_FILES                                                                       colon separated list of glob patterns, matched source files are included
[builder]     $BP_JAVA_INSTALL_NODE                  true                                             whether to install Yarn/Node binaries based on the presence of a package.json or yarn.lock file
[builder]     $BP_NODE_PROJECT_PATH                  frontend                                         configure a project subdirectory to look for `package.json` and `yarn.lock` files
[builder]     Creating cache directory /home/cnb/.gradle
[builder]   Compiled Application: Contributing to layer
[builder]     Executing gradlew --no-daemon -Dorg.gradle.welcome=never assemble
[builder]       Downloading https://services.gradle.org/distributions/gradle-7.6.2-bin.zip
[builder]       ...........10%............20%...........30%............40%............50%...........60%............70%............80%...........90%............100%
[builder]       To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.6.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
[builder]       Daemon will be stopped at the end of the build
[builder]
[builder]       FAILURE: Build failed with an exception.
[builder]
[builder]       * What went wrong:
[builder]       Could not open settings generic class cache for settings file '/workspace/settings.gradle' (/layers/paketo-buildpacks_gradle/cache/caches/7.6.2/scripts/du273tef1w9pufb5v7fbzfca5).
[builder]       > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65
[builder]
[builder]       * Try:
[builder]       > Run with --stacktrace option to get the stack trace.
[builder]       > Run with --info or --debug option to get more log output.
[builder]       > Run with --scan to get full insights.
[builder]
[builder]       * Get more help at https://help.gradle.org
[builder]
[builder]       BUILD FAILED in 15s
[builder] unable to invoke layer creator
[builder] unable to contribute application layer
[builder] error running build
[builder] exit status 1
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51

Motivations

dmikusa commented 3 days ago

I think it is the source compatibility flag in the build.gradle file. It's set to 17, so Gradle is complaining because it's building with Java 21. Can you try bumping that to Java 21?

We haven't bumped that example to use Java 21 yet, the instructions are still set to Java 17 (see README for that example), which indicates you should set BP_JVM_VERSION=17.