paketo-buildpacks / native-image

A Cloud Native Buildpack that creates native images from Java applications
Apache License 2.0
46 stars 9 forks source link

Spring Boot Native Image Build has been failed #297

Closed kworkbee closed 8 months ago

kworkbee commented 8 months ago

Expected Behavior

Originally, bootBuildImage task should run normally.

Current Behavior

It still has been failed.

Test Environment:

Logs are below:

> Running creator
    [creator]     ===> ANALYZING
    [creator]     Image with name "docker.io/library/demo:0.0.1-SNAPSHOT" not found
    [creator]     ===> DETECTING
    [creator]     6 of 15 buildpacks participating
    [creator]     paketo-buildpacks/ca-certificates   3.6.3
    [creator]     paketo-buildpacks/bellsoft-liberica 10.2.6
    [creator]     paketo-buildpacks/syft              1.32.1
    [creator]     paketo-buildpacks/executable-jar    6.7.4
    [creator]     paketo-buildpacks/spring-boot       5.26.1
    [creator]     paketo-buildpacks/native-image      5.12.1
    [creator]     ===> RESTORING
    [creator]     ===> BUILDING
    [creator]     
    [creator]     Paketo Buildpack for CA Certificates 3.6.3
    [creator]       https://github.com/paketo-buildpacks/ca-certificates
    [creator]       Launch Helper: Contributing to layer
    [creator]         Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
    [creator]     
    [creator]     Paketo Buildpack for BellSoft Liberica 10.2.6
    [creator]       https://github.com/paketo-buildpacks/bellsoft-liberica
    [creator]       Build Configuration:
    [creator]         $BP_JVM_JLINK_ARGS           --no-man-pages --no-header-files --strip-debug --compress=1  configure custom link arguments (--output must be omitted)
    [creator]         $BP_JVM_JLINK_ENABLED        false                                                        enables running jlink tool to generate custom JRE
    [creator]         $BP_JVM_TYPE                 JRE                                                          the JVM type - JDK or JRE
    [creator]         $BP_JVM_VERSION              17                                                           the Java version
    [creator]       Launch Configuration:
    [creator]         $BPL_DEBUG_ENABLED           false                                                        enables Java remote debugging support
    [creator]         $BPL_DEBUG_PORT              8000                                                         configure the remote debugging port
    [creator]         $BPL_DEBUG_SUSPEND           false                                                        configure whether to suspend execution until a debugger has attached
    [creator]         $BPL_HEAP_DUMP_PATH                                                                       write heap dumps on error to this path
    [creator]         $BPL_JAVA_NMT_ENABLED        true                                                         enables Java Native Memory Tracking (NMT)
    [creator]         $BPL_JAVA_NMT_LEVEL          summary                                                      configure level of NMT, summary or detail
    [creator]         $BPL_JFR_ARGS                                                                             configure custom Java Flight Recording (JFR) arguments
    [creator]         $BPL_JFR_ENABLED             false                                                        enables Java Flight Recording (JFR)
    [creator]         $BPL_JMX_ENABLED             false                                                        enables Java Management Extensions (JMX)
    [creator]         $BPL_JMX_PORT                5000                                                         configure the JMX port
    [creator]         $BPL_JVM_HEAD_ROOM           0                                                            the headroom in memory calculation
    [creator]         $BPL_JVM_LOADED_CLASS_COUNT  35% of classes                                               the number of loaded classes in memory calculation
    [creator]         $BPL_JVM_THREAD_COUNT        250                                                          the number of threads in memory calculation
    [creator]         $JAVA_TOOL_OPTIONS                                                                        the JVM launch flags
    [creator]         Using Java version 17 extracted from MANIFEST.MF
    [creator]       BellSoft Liberica NIK 17.0.7: Contributing to layer
    [creator]         Downloading from https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-core-openjdk17.0.7+7-23.0.0+1-linux-amd64.tar.gz
    [creator]         Verifying checksum
    [creator]         Expanding to /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm
    [creator]         Adding 137 container CA certificates to JVM truststore
    [creator]         Writing env.build/JAVA_HOME.override
    [creator]         Writing env.build/JDK_HOME.override
    [creator]     
    [creator]     Paketo Buildpack for Syft 1.32.1
    [creator]       https://github.com/paketo-buildpacks/syft
    [creator]         Downloading from https://github.com/anchore/syft/releases/download/v0.84.0/syft_0.84.0_linux_amd64.tar.gz
    [creator]         Verifying checksum
    [creator]         Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
    [creator]     
    [creator]     Paketo Buildpack for Executable JAR 6.7.4
    [creator]       https://github.com/paketo-buildpacks/executable-jar
    [creator]       Class Path: Contributing to layer
    [creator]         Writing env/CLASSPATH.delim
    [creator]         Writing env/CLASSPATH.prepend
    [creator]       Process types:
    [creator]         executable-jar: java org.springframework.boot.loader.JarLauncher (direct)
    [creator]         task:           java org.springframework.boot.loader.JarLauncher (direct)
    [creator]         web:            java org.springframework.boot.loader.JarLauncher (direct)
    [creator]     
    [creator]     Paketo Buildpack for Spring Boot 5.26.1
    [creator]       https://github.com/paketo-buildpacks/spring-boot
    [creator]       Build Configuration:
    [creator]         $BP_SPRING_CLOUD_BINDINGS_DISABLED   false  whether to contribute Spring Boot cloud bindings support
    [creator]       Launch Configuration:
    [creator]         $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false  whether to auto-configure Spring Boot environment properties from bindings
    [creator]         $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true   Deprecated - whether to auto-configure Spring Boot environment properties from bindings
    [creator]       Class Path: Contributing to layer
    [creator]         Writing env.build/CLASSPATH.append
    [creator]         Writing env.build/CLASSPATH.delim
    [creator]       Image labels:
    [creator]         org.opencontainers.image.title
    [creator]         org.opencontainers.image.version
    [creator]         org.springframework.boot.version
    [creator]     Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
    [creator]     
    [creator]     Paketo Buildpack for Native Image 5.12.1
    [creator]       https://github.com/paketo-buildpacks/native-image
    [creator]       Build Configuration:
    [creator]         $BP_BINARY_COMPRESSION_METHOD                Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
    [creator]         $BP_NATIVE_IMAGE                       true  enable native image build
    [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS             arguments to pass to the native-image command
    [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE        a file with arguments to pass to the native-image command
    [creator]         $BP_NATIVE_IMAGE_BUILT_ARTIFACT              the built application artifact explicitly, required if building from a JAR
    [creator]       Native Image: Contributing to layer
    [creator]         Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.demo.DemoApplication -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-cloud-starter-netflix-eureka-server-4.0.3.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-loadbalancer-4.0.4.jar:/workspace/BOOT-INF/lib/spring-cloud-starter-4.0.4.jar:/workspace/BOOT-INF/lib/spring-cloud-netflix-eureka-server-4.0.3.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-autoconfigure-3.1.5.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.1.5.jar:/workspace/BOOT-INF/lib/spring-boot-actuator-3.1.5.jar:/workspace/BOOT-INF/lib/spring-boot-3.1.5.jar:/workspace/BOOT-INF/lib/jaxb-runtime-4.0.3.jar:/workspace/BOOT-INF/lib/spring-bridge-3.0.3.jar:/workspace/BOOT-INF/lib/spring-webmvc-6.0.13.jar:/workspace/BOOT-INF/lib/spring-context-support-6.0.13.jar:/workspace/BOOT-INF/lib/spring-context-6.0.13.jar:/workspace/BOOT-INF/lib/spring-aop-6.0.13.jar:/workspace/BOOT-INF/lib/spring-web-6.0.13.jar:/workspace/BOOT-INF/lib/spring-beans-6.0.13.jar:/workspace/BOOT-INF/lib/spring-expression-6.0.13.jar:/workspace/BOOT-INF/lib/spring-core-6.0.13.jar:/workspace/BOOT-INF/lib/spring-cloud-loadbalancer-4.0.4.jar:/workspace/BOOT-INF/lib/spring-cloud-context-4.0.4.jar:/workspace/BOOT-INF/lib/spring-cloud-commons-4.0.4.jar:/workspace/BOOT-INF/lib/spring-security-rsa-1.0.12.RELEASE.jar:/workspace/BOOT-INF/lib/spring-cloud-netflix-eureka-client-4.0.3.jar:/workspace/BOOT-INF/lib/eureka-core-jersey3-2.0.1.jar:/workspace/BOOT-INF/lib/eureka-client-jersey3-2.0.1.jar:/workspace/BOOT-INF/lib/jersey-container-servlet-3.1.3.jar:/workspace/BOOT-INF/lib/jersey-container-servlet-core-3.1.3.jar:/workspace/BOOT-INF/lib/jersey-server-3.1.3.jar:/workspace/BOOT-INF/lib/jersey-apache-connector-3.1.3.jar:/workspace/BOOT-INF/lib/jersey-client-3.1.3.jar:/workspace/BOOT-INF/lib/jersey-hk2-3.1.3.jar:/workspace/BOOT-INF/lib/eureka-core-2.0.1.jar:/workspace/BOOT-INF/lib/eureka-client-2.0.1.jar:/workspace/BOOT-INF/lib/jersey-common-3.1.3.jar:/workspace/BOOT-INF/lib/hk2-locator-3.0.4.jar:/workspace/BOOT-INF/lib/hk2-api-3.0.4.jar:/workspace/BOOT-INF/lib/hk2-utils-3.0.4.jar:/workspace/BOOT-INF/lib/jakarta.inject-api-2.0.1.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-databind-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-core-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.15.3.jar:/workspace/BOOT-INF/lib/jackson-dataformat-xml-2.15.3.jar:/workspace/BOOT-INF/lib/evictor-1.0.0.jar:/workspace/BOOT-INF/lib/jaxb-core-4.0.3.jar:/workspace/BOOT-INF/lib/spring-jcl-6.0.13.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/snakeyaml-1.33.jar:/workspace/BOOT-INF/lib/spring-security-crypto-6.1.5.jar:/workspace/BOOT-INF/lib/bcpkix-jdk18on-1.73.jar:/workspace/BOOT-INF/lib/micrometer-core-1.11.5.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.11.5.jar:/workspace/BOOT-INF/lib/freemarker-2.3.32.jar:/workspace/BOOT-INF/lib/httpclient5-5.2.1.jar:/workspace/BOOT-INF/lib/jakarta.ws.rs-api-3.1.0.jar:/workspace/BOOT-INF/lib/jakarta.validation-api-3.0.2.jar:/workspace/BOOT-INF/lib/javassist-3.29.2-GA.jar:/workspace/BOOT-INF/lib/woodstox-core-6.5.1.jar:/workspace/BOOT-INF/lib/stax2-api-4.2.1.jar:/workspace/BOOT-INF/lib/reactor-extra-3.5.1.jar:/workspace/BOOT-INF/lib/reactor-core-3.5.11.jar:/workspace/BOOT-INF/lib/jakarta.xml.bind-api-4.0.1.jar:/workspace/BOOT-INF/lib/angus-activation-2.0.1.jar:/workspace/BOOT-INF/lib/jakarta.activation-api-2.1.2.jar:/workspace/BOOT-INF/lib/txw2-4.0.3.jar:/workspace/BOOT-INF/lib/istack-commons-runtime-4.1.2.jar:/workspace/BOOT-INF/lib/logback-classic-1.4.11.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.20.0.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.9.jar:/workspace/BOOT-INF/lib/bcutil-jdk18on-1.73.jar:/workspace/BOOT-INF/lib/bcprov-jdk18on-1.73.jar:/workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.15.jar:/workspace/BOOT-INF/lib/tomcat-embed-core-10.1.15.jar:/workspace/BOOT-INF/lib/tomcat-embed-el-10.1.15.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.11.5.jar:/workspace/BOOT-INF/lib/HdrHistogram-2.1.12.jar:/workspace/BOOT-INF/lib/LatencyUtils-2.0.3.jar:/workspace/BOOT-INF/lib/netflix-eventbus-0.3.0.jar:/workspace/BOOT-INF/lib/xstream-1.4.19.jar:/workspace/BOOT-INF/lib/servo-core-0.12.21.jar:/workspace/BOOT-INF/lib/httpclient-4.5.14.jar:/workspace/BOOT-INF/lib/commons-configuration-1.10.jar:/workspace/BOOT-INF/lib/jettison-1.4.0.jar:/workspace/BOOT-INF/lib/httpcore5-h2-5.2.3.jar:/workspace/BOOT-INF/lib/httpcore5-5.2.3.jar:/workspace/BOOT-INF/lib/netflix-infix-0.3.0.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.9.jar:/workspace/BOOT-INF/lib/jakarta.servlet-api-6.0.0.jar:/workspace/BOOT-INF/lib/osgi-resource-locator-1.0.3.jar:/workspace/BOOT-INF/lib/aopalliance-repackaged-3.0.4.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/logback-core-1.4.11.jar:/workspace/BOOT-INF/lib/log4j-api-2.20.0.jar:/workspace/BOOT-INF/lib/commons-math-2.2.jar:/workspace/BOOT-INF/lib/mxparser-1.2.2.jar:/workspace/BOOT-INF/lib/guava-19.0.jar:/workspace/BOOT-INF/lib/commons-lang-2.6.jar:/workspace/BOOT-INF/lib/httpcore-4.4.16.jar:/workspace/BOOT-INF/lib/commons-codec-1.15.jar:/workspace/BOOT-INF/lib/commons-jxpath-1.3.jar:/workspace/BOOT-INF/lib/joda-time-2.3.jar:/workspace/BOOT-INF/lib/antlr-runtime-3.4.jar:/workspace/BOOT-INF/lib/gson-2.10.1.jar:/workspace/BOOT-INF/lib/xmlpull-1.1.3.1.jar:/workspace/BOOT-INF/lib/stringtemplate-3.2.1.jar:/workspace/BOOT-INF/lib/antlr-2.7.7.jar com.example.demo.DemoApplication
    [creator]     Warning: The USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM environment variable is deprecated and might be removed in a future release. Please refer to the GraalVM release notes.
    [creator]     #
    [creator]     # A fatal error has been detected by the Java Runtime Environment:
    [creator]     #
    [creator]     #  SIGSEGV (0xb) at pc=0x00007fffe6967571, pid=194, tid=220
    [creator]     #
    [creator]     # JRE version: OpenJDK Runtime Environment Liberica-NIK-23.0.0-1 (17.0.7+7) (build 17.0.7+7-LTS)
    [creator]     # Java VM: OpenJDK 64-Bit Server VM Liberica-NIK-23.0.0-1 (17.0.7+7-LTS, mixed mode, tiered, jvmci, compressed oops, compressed class ptrs, parallel gc, linux-amd64)
    [creator]     # Problematic frame:
    [creator]     # J 1993 c2 org.graalvm.collections.EconomicMapImpl.put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; org.graalvm.sdk (192 bytes) @ 0x00007fffe6967571 [0x00007fffe6966ae0+0x0000000000000a91]
    [creator]     #
    [creator]     # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
    [creator]     #
    [creator]     # An error report file with more information is saved as:
    [creator]     # /layers/paketo-buildpacks_native-image/native-image/hs_err_pid194.log
    [creator]     #
    [creator]     # If you would like to submit a bug report, please visit:
    [creator]     #   https://bell-sw.com/support
    [creator]     #
    [creator]     Error: Image build request for 'com.example.demo.DemoApplication' (pid: 194, path: /layers/paketo-buildpacks_native-image/native-image) failed with exit status 134
    [creator]     unable to invoke layer creator
    [creator]     unable to contribute native-image layer
    [creator]     error running build
    [creator]     exit status 134
    [creator]     ERROR: failed to build: exit status 1

Possible Solution

Steps to Reproduce

  1. Create Project via start.spring.io with latest versions and GraalVM Plugin
  2. Just Run bootBuildImage task

Motivations

It affects everyone who uses the latest Spring Boot project.

kworkbee commented 8 months ago

Apart from the above issue, is there any way to deal with the following error when you directly designate buildpacks option?

ERROR: failed to initialize detector: open /cnb/buildpacks/paketo-buildpacks_adoptium/11.0.0/buildpack.toml: no such file or directory
dmikusa commented 8 months ago

Not the exact same symptoms, but possibly related. We had this issue come in: https://github.com/buildpacks/pack/issues/1959 and the reporter said that it looked to be caused by this Docker Mac issue https://github.com/docker/for-mac/issues/7006. Maybe worth checking out.

Other thoughts:

  1. Try with GraalVM instead of Bellsoft NIK and see if that changes anything.
  2. Try with different versions and see if you also get crashes.

Just trying to narrow down what might be causing this.

scottfrederick commented 8 months ago

@kworkbee When using Spring Boot 3.1, be sure to configure your build to use the latest Paketo builder as described in this blog post: https://spring.io/blog/2023/09/22/paketo-buildpacks-bionic-end-of-support.

mhalbritter commented 8 months ago

You're using an ARM mac. Buildpacks don't have native support for ARM yet. In the logs I can see that it downloads the x64 version of the JDK, so there is some kind of emulation going on here (Rosetta?). Maybe that's causing the problem?

kworkbee commented 8 months ago

@mhalbritter

As you mentioned, The option Use Rosetta for x86/amd64 emulation on Apple Silicon was enabled (on Docker Settings). Disabling and re-running again, it's working fine! This is something I never thought of, and I'm glad it's solved right away! Thanks for your help!

Screenshot 2023-11-09 11 01 35

I'll close the issue because it was caused by Docker Settings.