paketo-buildpacks / native-image

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

com.oracle.svm.driver.NativeImage$NativeImageError: Unknown name in option specification: macro:truffle-svm #345

Closed qa137 closed 1 month ago

qa137 commented 7 months ago

Use the following command to execute the compilation and everything works: mvn -Pnative clean native:compile However, executing with the following command fails: mvn -Pnative clean spring-boot:build-image

Describe GraalVM and your environment: GraalVM version: Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37) JDK major version: 21.0.3 (2024-04-16 LTS) OS: macOS Sonoma 14.2.1 Architecture: AMD64

pom.xml

<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>3.2.5</version>
      <relativePath/>
</parent>
<dependencies>
    <dependency>
          <groupId>org.graalvm.polyglot</groupId>
          <artifactId>polyglot</artifactId>
          <version>23.1.3</version>
    </dependency>
    <dependency>
          <groupId>org.graalvm.polyglot</groupId>
          <artifactId>js-community</artifactId>
          <version>23.1.3</version>
          <type>pom</type>
    </dependency>
</dependencies>

More details:

[INFO]  > Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-tiny:latest' 100%
[INFO]  > Pulled builder image 'paketobuildpacks/builder-jammy-tiny@sha256:700967dfd9f746684fa5dbf9d747292cff070d3474b61618417d4263701a05ce'
[INFO]  > Pulling run image 'docker.io/paketobuildpacks/run-jammy-tiny:latest' 100%
[INFO]  > Pulled run image 'paketobuildpacks/run-jammy-tiny@sha256:abfbd966ad2e71fc771b3bbfcf683fdfa10277b053742cd25de61e91e5891fa5'
[INFO]  > Executing lifecycle version v0.19.3
[INFO]  > Using build cache volume 'pack-cache-b074b534d156.build'
[INFO] 
[INFO]  > Running creator
[INFO]     [creator]     ===> ANALYZING
[INFO]     [creator]     Image with name "docker.io/library/server-concrete:1.0.7" not found
[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     7 of 15 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.7.0
[INFO]     [creator]     paketo-buildpacks/upx               3.5.0
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.7.0
[INFO]     [creator]     paketo-buildpacks/syft              1.45.0
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.9.0
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.28.0
[INFO]     [creator]     paketo-buildpacks/native-image      5.13.0
[INFO]     [creator]     ===> RESTORING
[INFO]     [creator]     ===> BUILDING
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for CA Certificates 3.7.0
[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 UPX 3.5.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/upx
[INFO]     [creator]         Downloading from https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for BellSoft Liberica 10.7.0
[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              17                                                           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 extracted from MANIFEST.MF
[INFO]     [creator]       BellSoft Liberica NIK 21.0.3: Contributing to layer
[INFO]     [creator]         Downloading from https://github.com/bell-sw/LibericaNIK/releases/download/23.1.3+1-21.0.3+10/bellsoft-liberica-vm-core-openjdk21.0.3+10-23.1.3+1-linux-amd64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Expanding to /layers/paketo-buildpacks_bellsoft-liberica/native-image-svm
[INFO]     [creator]         Adding 137 container CA certificates to JVM truststore
[INFO]     [creator]         Writing env.build/JAVA_HOME.override
[INFO]     [creator]         Writing env.build/JDK_HOME.override
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Syft 1.45.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/syft
[INFO]     [creator]         Downloading from https://github.com/anchore/syft/releases/download/v0.105.0/syft_0.105.0_linux_amd64.tar.gz
[INFO]     [creator]         Verifying checksum
[INFO]     [creator]         Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Executable JAR 6.9.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/executable-jar
[INFO]     [creator]       Command "packages" is deprecated, use `syft scan` instead
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         Writing env/CLASSPATH.delim
[INFO]     [creator]         Writing env/CLASSPATH.prepend
[INFO]     [creator]       Process types:
[INFO]     [creator]         executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]         task:           java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]         web:            java org.springframework.boot.loader.launch.JarLauncher (direct)
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Spring Boot 5.28.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/spring-boot
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_SPRING_CLOUD_BINDINGS_DISABLED   false  whether to contribute Spring Boot cloud bindings support
[INFO]     [creator]         $BP_SPRING_CLOUD_BINDINGS_VERSION    1      default version of Spring Cloud Bindings library to contribute
[INFO]     [creator]       Launch Configuration:
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_DISABLED  false  whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]         $BPL_SPRING_CLOUD_BINDINGS_ENABLED   true   Deprecated - whether to auto-configure Spring Boot environment properties from bindings
[INFO]     [creator]       Class Path: Contributing to layer
[INFO]     [creator]         Writing env.build/CLASSPATH.append
[INFO]     [creator]         Writing env.build/CLASSPATH.delim
[INFO]     [creator]       Image labels:
[INFO]     [creator]         org.opencontainers.image.title
[INFO]     [creator]         org.opencontainers.image.version
[INFO]     [creator]         org.springframework.boot.version
[INFO]     [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>.
[INFO]     [creator]     
[INFO]     [creator]     Paketo Buildpack for Native Image 5.13.0
[INFO]     [creator]       https://github.com/paketo-buildpacks/native-image
[INFO]     [creator]       Build Configuration:
[INFO]     [creator]         $BP_BINARY_COMPRESSION_METHOD          upx                                                                                                                                                                                                                                                                                                                                                                      Compression mechanism used to reduce binary size. Options: `none` (default), `upx` or `gzexe`
[INFO]     [creator]         $BP_NATIVE_IMAGE                       true                                                                                                                                                                                                                                                                                                                                                                     enable native image build
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS       -march=compatibility
[INFO]     [creator]                                         --enable-url-protocols=http
[INFO]     [creator]                                         -Dfile.encoding=UTF-8
[INFO]     [creator]                                         -Dsun.jnu.encoding=UTF-8
[INFO]     [creator]                                         -H:+AddAllCharsets
[INFO]     [creator]                                         -Duser.language=zh_CN
[INFO]     [creator]                                         -H:+ReportExceptionStackTraces  arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE                                                                                                                                                                                                                                                                                                                                                                           a file with arguments to pass to the native-image command
[INFO]     [creator]         $BP_NATIVE_IMAGE_BUILT_ARTIFACT                                                                                                                                                                                                                                                                                                                                                                                 the built application artifact explicitly, required if building from a JAR
[INFO]     [creator]       Command "packages" is deprecated, use `syft scan` instead
[INFO]     [creator]       Native Image: Contributing to layer
[INFO]     [creator]         Executing native-image --no-fallback -H:+StaticExecutableWithDynamicLibC -march=compatibility --enable-url-protocols=http -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -H:+AddAllCharsets -Duser.language=zh_CN -H:+ReportExceptionStackTraces -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.xietong.serverconcrete.ServerConcreteApplication -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-boot-3.2.5.jar:/workspace/BOOT-INF/lib/spring-context-6.1.6.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.2.5.jar:/workspace/BOOT-INF/lib/logback-classic-1.4.14.jar:/workspace/BOOT-INF/lib/logback-core-1.4.14.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.21.1.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.13.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/spring-core-6.1.6.jar:/workspace/BOOT-INF/lib/spring-jcl-6.1.6.jar:/workspace/BOOT-INF/lib/snakeyaml-2.2.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.15.4.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.15.4.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.15.4.jar:/workspace/BOOT-INF/lib/tomcat-embed-core-10.1.20.jar:/workspace/BOOT-INF/lib/tomcat-embed-el-10.1.20.jar:/workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.20.jar:/workspace/BOOT-INF/lib/spring-web-6.1.6.jar:/workspace/BOOT-INF/lib/spring-beans-6.1.6.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.12.5.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.12.5.jar:/workspace/BOOT-INF/lib/spring-webmvc-6.1.6.jar:/workspace/BOOT-INF/lib/spring-aop-6.1.6.jar:/workspace/BOOT-INF/lib/spring-expression-6.1.6.jar:/workspace/BOOT-INF/lib/spring-messaging-6.1.6.jar:/workspace/BOOT-INF/lib/spring-websocket-6.1.6.jar:/workspace/BOOT-INF/lib/minio-8.5.9.jar:/workspace/BOOT-INF/lib/simple-xml-safe-2.7.1.jar:/workspace/BOOT-INF/lib/guava-33.0.0-jre.jar:/workspace/BOOT-INF/lib/failureaccess-1.0.2.jar:/workspace/BOOT-INF/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/workspace/BOOT-INF/lib/jsr305-3.0.2.jar:/workspace/BOOT-INF/lib/checker-qual-3.41.0.jar:/workspace/BOOT-INF/lib/error_prone_annotations-2.23.0.jar:/workspace/BOOT-INF/lib/j2objc-annotations-2.8.jar:/workspace/BOOT-INF/lib/okhttp-4.12.0.jar:/workspace/BOOT-INF/lib/okio-3.6.0.jar:/workspace/BOOT-INF/lib/okio-jvm-3.6.0.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-common-1.9.23.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk8-1.9.23.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-1.9.23.jar:/workspace/BOOT-INF/lib/annotations-13.0.jar:/workspace/BOOT-INF/lib/kotlin-stdlib-jdk7-1.9.23.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.15.4.jar:/workspace/BOOT-INF/lib/jackson-core-2.15.4.jar:/workspace/BOOT-INF/lib/jackson-databind-2.15.4.jar:/workspace/BOOT-INF/lib/bcprov-jdk18on-1.77.jar:/workspace/BOOT-INF/lib/commons-compress-1.26.0.jar:/workspace/BOOT-INF/lib/commons-io-2.15.1.jar:/workspace/BOOT-INF/lib/commons-lang3-3.13.0.jar:/workspace/BOOT-INF/lib/commons-codec-1.16.1.jar:/workspace/BOOT-INF/lib/snappy-java-1.1.10.5.jar:/workspace/BOOT-INF/lib/alibabacloud-push20160801-1.0.5.jar:/workspace/BOOT-INF/lib/aliyun-gateway-pop-0.2.4-beta.jar:/workspace/BOOT-INF/lib/darabonba-java-core-0.2.4-beta.jar:/workspace/BOOT-INF/lib/aliyun-http-apache-0.2.4-beta.jar:/workspace/BOOT-INF/lib/httpclient5-5.2.3.jar:/workspace/BOOT-INF/lib/httpcore5-5.2.4.jar:/workspace/BOOT-INF/lib/httpcore5-h2-5.2.4.jar:/workspace/BOOT-INF/lib/gson-2.10.1.jar:/workspace/BOOT-INF/lib/aliyun-java-core-0.2.4-beta.jar:/workspace/BOOT-INF/lib/dom4j-2.1.3.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/aliyun-java-auth-0.2.4-beta.jar:/workspace/BOOT-INF/lib/ini4j-0.5.4.jar:/workspace/BOOT-INF/lib/bcprov-jdk15on-1.70.jar:/workspace/BOOT-INF/lib/alibabacloud-dysmsapi20170525-2.0.24.jar:/workspace/BOOT-INF/lib/develop-common-1.0.6.jar:/workspace/BOOT-INF/lib/h2-2.2.224.jar:/workspace/BOOT-INF/lib/mssql-jdbc-12.4.2.jre11.jar:/workspace/BOOT-INF/lib/mysql-connector-j-8.3.0.jar:/workspace/BOOT-INF/lib/HikariCP-5.0.1.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.13.jar:/workspace/BOOT-INF/lib/json-20231013.jar:/workspace/BOOT-INF/lib/log4j-core-2.21.1.jar:/workspace/BOOT-INF/lib/log4j-api-2.21.1.jar:/workspace/BOOT-INF/lib/polyglot-23.1.3.jar:/workspace/BOOT-INF/lib/collections-23.1.3.jar:/workspace/BOOT-INF/lib/nativeimage-23.1.3.jar:/workspace/BOOT-INF/lib/word-23.1.3.jar:/workspace/BOOT-INF/lib/js-language-23.1.3.jar:/workspace/BOOT-INF/lib/regex-23.1.3.jar:/workspace/BOOT-INF/lib/truffle-api-23.1.3.jar:/workspace/BOOT-INF/lib/icu4j-23.1.3.jar:/workspace/BOOT-INF/lib/truffle-runtime-23.1.3.jar:/workspace/BOOT-INF/lib/jniutils-23.1.3.jar:/workspace/BOOT-INF/lib/truffle-compiler-23.1.3.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-3.2.5.jar com.xietong.serverconcrete.ServerConcreteApplication
[INFO]     [creator]     Error: Processing jar:file:///workspace/BOOT-INF/lib/truffle-api-23.1.3.jar!/META-INF/native-image/org.graalvm.truffle/native-image.properties failed
[INFO]     [creator]     Caused by: com.oracle.svm.driver.NativeImage$NativeImageError: Unknown name in option specification: macro:truffle-svm
[INFO]     [creator]     Available macro options are:
[INFO]     [creator]         --macro:junit
[INFO]     [creator]         --macro:native-image-agent-library
[INFO]     [creator]         --macro:native-image-configure-launcher
[INFO]     [creator]         --macro:native-image-diagnostics-agent-library
[INFO]     [creator]         --macro:native-image-launcher
[INFO]     [creator]     unable to invoke layer creator
[INFO]     [creator]     unable to contribute native-image layer
[INFO]     [creator]     error running build
[INFO]     [creator]     exit status 20
[INFO]     [creator]     ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:01 min
[INFO] Finished at: 2024-04-20T21:14:09+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.5:build-image (default-cli) on project server-concrete: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.2.5:build-image failed: Builder lifecycle 'creator' failed with status code 51 -> [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.
kubav182 commented 1 month ago

any solution? same problem with python

dmikusa commented 1 month ago

You are asking native-image for functionality that it doesn't have. It's telling you what is available:

[INFO]     [creator]     Caused by: com.oracle.svm.driver.NativeImage$NativeImageError: Unknown name in option specification: macro:truffle-svm
[INFO]     [creator]     Available macro options are:
[INFO]     [creator]         --macro:junit
[INFO]     [creator]         --macro:native-image-agent-library
[INFO]     [creator]         --macro:native-image-configure-launcher
[INFO]     [creator]         --macro:native-image-diagnostics-agent-library
[INFO]     [creator]         --macro:native-image-launcher

I don't know why that's unavailable, but check your version. Do you need NIK 23? That is available, but buildpacks are installing 21 according to what you posted. Other possibility, are you using something that requires the Oracle GraalVM? The default is to install Bellsoft NIK, but you can swap in Oracle GraalVM (or GraalVM CE) if you want, see here.

kubav182 commented 1 month ago

you are right, it works with oracle graalvm jdk23, thanks

dmikusa commented 1 month ago

Ah, great. Thanks for sharing the fix!