I used https://start.spring.io/ to create a new Java Spring Boot 3.0.1 project with Maven and Java 19.
Running mvn -P native spring-boot:build-image fails with
[INFO] [creator] Paketo Buildpack for BellSoft Liberica 9.10.1
[INFO] [creator] unable to find dependency
[INFO] [creator] no valid dependencies for native-image-svm, 19, and io.paketo.stacks.tiny in [(jdk, 8.0.352, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 8.0.352, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 11.0.17, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 11.0.17, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 11.0.17, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 17.0.5, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 17.0.5, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 17.0.5, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 19.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 19.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *])]
[INFO] [creator] ERROR: failed to build: exit status 1
I tested on both Linux as well as Windows. Am I missing something?
Comment From: philwebb
I don't believe there's a buildpack release available yet for creating native images with Java 19. I think we're waiting for a Bellsoft release. Looking at https://bell-sw.com/pages/downloads/native-image-kit/#downloads release only go up to JDK 17.
I'm afraid you'll need to downgrade or try building an image directly rather than using a buildpack.
Comment From: scottfrederick
The Paketo builder used by default with the Spring Boot Maven plugin's spring-boot:build-image uses the Bellsoft Liberica buildpack by default. That buildpack installs the Bellsoft NIK for compiling native images, which is not compatible with Java 19. See this Paketo issue for more details: https://github.com/paketo-buildpacks/bellsoft-liberica/issues/345.
If you need to use Java 19, you can configure your build to use the Paketo GraalVM buildpack instead. That would look something like this:
<project>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<buildpacks>
<buildpack>gcr.io/paketo-buildpacks/graalvm</buildpack>
<buildpack>urn:cnb:builder:paketo-buildpacks/java-native-image</buildpack>
</buildpacks>
</image>
</configuration>
</plugin>
</plugins>
</build>
</project>
Comment From: biergit
Thanks for your help 👍
Comment From: biergit
FYI the above config does not work for me either:
Caused by: java.lang.IllegalArgumentException: Invalid buildpack reference 'paketo-buildpacks/graalvm' at org.springframework.boot.buildpack.platform.build.BuildpackResolvers.resolve (BuildpackResolvers.java:77)
Edit: Ok it is somehow related to my Windows environment. It works under Linux. Next exception is:
[INFO] [creator] ERROR: failed to initialize detector: open /cnb/buildpacks/paketo-buildpacks_graalvm/7.9.0/buildpack.toml: no such file or directory
Comment From: scottfrederick
@biergit I updated the sample configuration in the comment above. I had taken the previous configuration from the Paketo documentation on this topic, but that documentation does not appear to be correct. It implies that the Paketo GraalVM buildpack is avalable on Docker Hub (as the image reference paketo-buildpacks/graalvm implies docker.io/paketo-buildpacks/graavm:latest), but that buildpack does not appear to be published to the Paketo org on Docker Hub.
I've tested the above configuration with mvn -P native spring-boot:build-image and it works for me.
Comment From: biergit
Hey @scottfrederick thanks for taking another look. Even with your change I get this error. I assume it has to do with using Podman instead of Docker. I saw there is some documentation for Podman and the Spring Boot Maven plugin but I guess it is Unix specific?
Comment From: scottfrederick
The podman support in the Spring Boot Maven plugin should not be Unix/Linux specific, although the example given in the documentation is for Linux. Unfortunately we can't give much support on how to configure this on Windows. You can try running podman info --format='{{.Host.RemoteSocket.Path}}' or just podman info to see if that provides a value to use with the docker.host configuration in the Spring Boot plugin.
Comment From: biergit
I could successfully build the native image with pack (pack build --builder paketobuildpacks/builder:tiny --path .\target\nativesandbox-0.0.1-SNAPSHOT.jar --env 'BP_NATIVE_IMAGE=true' --buildpack gcr.io/paketo-buildpacks/gra
alvm,paketo-buildpacks/java-native-image nativesandbox) so I assume the issue is with the Spring Boot Maven plugin.