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

Error: Processing jar:file:///workspace/BOOT-INF/lib/truffle-api-23.1.4.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 #340

Closed nadeemahmad770 closed 1 month ago

nadeemahmad770 commented 1 month ago

Used the following command to execute the compilation and everything works: mvn -Pnative -DskipTests package -X

However, executing with the following command fails: mvn -Pnative clean spring-boot:build-image

Describing GraalVM and environment: GraalVM version: Oracle graalvm-jdk-21.0.4+8.1 JDK major version: 21.0.3 (2024-04-16 LTS) OS: Linux Architecture: AMD64

Expected Behavior

Expecting a success native-build with GraalJS features (Polyglot)

Current Behavior

We are using graalJS with polyglot module and Paketo Buildpack fails the build as it is unable to use macro:truffle-svm arg

Possible Solution

Steps to Reproduce

org.springframework.boot spring-boot-starter-parent 3.2.3 org.graalvm.polyglot polyglot 23.1.4
    <dependency>
        <groupId>org.graalvm.polyglot</groupId>
        <artifactId>js</artifactId>
        <version>23.1.4</version>
        <type>pom</type>
    </dependency>

build the app with mvn -Pnative clean spring-boot:build-image

Logs:

Security report:

Please suggest if there is any other latest version available which can help in solving this issue.

dmikusa commented 1 month ago

Off the top of my head, it sounds like we may be missing something in the GraalVM install that you have installed locally. How did you install GraalVM locally?

The buildpacks you have running are fetching GraalVM (Bellsoft NIK) from here. Can you give that a try and see if you have similar issues locally?

You can also try different vendors with buildpacks and see if that helps. See https://paketo.io/docs/howto/java/#use-an-alternative-java-native-image-toolkit It would be helpful to know if you have the same issue for all vendors.

Thanks

nadeemahmad770 commented 1 month ago

Thank you @dmikusa for your response.

Issue got resolved by changing the buildpacks version in the image configuration under maven plugin. Fixed with following config:

<image>
    <name>${module.image.name}</name>
    <env>
        <BP_JVM_VERSION>21.0.2</BP_JVM_VERSION>
        <BP_GRAALVM_VERSION>21.0.2</BP_GRAALVM_VERSION>
    </env>
    <buildpacks>
        <buildpack>gcr.io/paketo-buildpacks/graalvm</buildpack>
        <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
    </buildpacks>
</image>

dmikusa commented 1 month ago

Excellent! Thanks for sharing the fix.