Closed clockworkmay closed 3 months ago
/cc @Karm (mandrel), @galderz (mandrel), @geoand (knative), @iocanel (knative), @zakkak (mandrel)
@radcortez I'm surprised this has not been an issue before
Hum... very strange. Look at the reported class: https://github.com/quarkusio/quarkus/blob/ebee0a4b66d1b4dba9c51165e78d22fbf3b90d3e/core/runtime/src/main/java/io/quarkus/runtime/configuration/CidrAddressConverter.java
The line numbers reported in the stacktrace do not make sense. Also, this class was last touched with the Jakarta rename.
Very weird indeed...
@clockworkmay can you please also share the tutorial code in a small reproducer? From the stacktrace it seems you have something like:
@ConfigProperty(...)
Optional<CidrAddress> cidrAddress;
Which should work (I've just tried it). We need the full code to properly assess the problem. Thank you!
I wonder if we should remove io.quarkus.runtime.graal.Target_org_wildfly_common_net_Inet
and instead mark Inet
as rerun-initialization instead. It's failing while looking for a write-accessor on Inet for fields which are static-final, which makes me wonder if it is already trying to rerun static init for some reason? Maybe only when CidrAddress
is reachable?
In any case, GraalVM did (at one point, maybe still) forbid instances of InetAddress
from being on the build time heap. This may mean that one cannot build a native image with "build time run time fixed" configuration properties of that type or any type that contains that type (e.g. CidrAddress
). A workaround could be to make the property in question be run time config instead.
Yes, of course. The code came mostly from the Quarkus Configurator and is using the following packages:
I also am not sure where the cidrAddress
is being called. I am assuming from one of the libraries. A global search in Intellj for cidrAddress
is coming up empty. I've pushed the code to Github (pardon the hardcoded database passwords, I'll slowly make my way to better security measures):
git clone https://github.com/clockworkmay/rest-api-java.git
cd rest-api-java
pack build rest-api-java-buildpacknative --path .\ --env BP_MAVEN_ACTIVE_PROFILES=native --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21"
I did try your reproducer with a native local build, and it worked as expected. I've also built the native image with the quarkus cli and docker with no issues.
I did try with pack
and noticed a successful native image build in Paketo Buildpack for Maven 6.17.3
and a failed second native image build in Paketo Buildpack for Native Image 5.14.1
. What puzzles me is that while I get the same error as you, the reported line is different but still does not make any sense with the actual code.
We may be able to fix it with @dmlloyd recommendation, but I also feel that there is some issue with how pack
builds the native image.
@radcortez thank you for the follow up.
In case it matters, pack build test_javanativeimage --path . --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21" --env "BP_MAVEN_ACTIVE_PROFILES=native" --env "BP_NATIVE_IMAGE=true"
uses
===> DETECTING
target distro name/version labels not found, reading /etc/os-release file
7 of 15 buildpacks participating
paketo-buildpacks/ca-certificates 3.8.2
paketo-buildpacks/bellsoft-liberica 10.8.1
paketo-buildpacks/syft 1.47.1
paketo-buildpacks/maven 6.17.3
paketo-buildpacks/executable-jar 6.10.1
paketo-buildpacks/spring-boot 5.30.1
paketo-buildpacks/native-image 5.14.1
on my machine, in case that matters.
I'm not too attached to any of the process and am not too knowledgeable about docker or web deployment myself at the moment. I'm mainly using pack
because I was following this tutorial (https://www.codecentric.de/wissens-hub/blog/spring-boot-flyio), need containers to use Fly.io, and want to build to native to reduce the memory/size footprint. My only real attachment is to Java, since that's what I know. Is the recommend route to use docker?
I wasn't able to get a container native build working with Maven 6.17.3
though. pack build test_maven --path . --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/maven --env "BP_JVM_VERSION=21" --env "BP_MAVEN_ACTIVE_PROFILES=native" --env "BP_NATIVE_IMAGE=true"
gets me a
===> DETECTING
target distro name/version labels not found, reading /etc/os-release file
======== Results ========
pass: paketo-buildpacks/maven@6.17.3
pass: paketo-buildpacks/syft@1.47.1
Resolving plan... (try #1)
fail: paketo-buildpacks/maven@6.17.3 requires jdk
Resolving plan... (try #2)
fail: paketo-buildpacks/maven@6.17.3 requires syft
Resolving plan... (try #3)
fail: paketo-buildpacks/maven@6.17.3 requires syft
ERROR: No buildpack groups passed detection.
ERROR: Please check that you are running against the correct path.
ERROR: failed to detect: no buildpacks participating
ERROR: failed to build: executing lifecycle: failed with status code: 20
that I've been trying to resolve.
What we recommend is our guide to building a native executable that will work: https://quarkus.io/guides/building-native-image
We don't really control what other tools like pack
do the build. An issue has to be filled on their side. If they can show us that it is our problem, we will happily fix it.
Describe the bug
Working through a small tutorial which builds properly when I run
mvnw clean install -Dnative "-Dquarkus.container-image.build=true" "-Dquarkus.native.container-build=true" "-Dquarkus.buildpack.builder-env.BP_JVM_VERSION=17"
(though it does oddly lead to a larger executable that uses more memory in Docker, but I will file a separate issue for that).The build also works correctly without native compile in buildpack:
pack build rest-api-java-buildpacknative --path .\ --builder paketobuildpacks/builder-jammy-tiny
However, when I try to build to native container, I am unable to complete the build. I wasn't able to find a similar issue, but if there is something similar, please let me know. Thank you.
Expected behavior
Build successfully
Actual behavior
Error stack and context:
How to Reproduce?
pack build rest-api-java -b paketo-buildpacks/oracle -b urn:cnb:builder:paketo-buildpacks/java-native-image --builder paketobuildpacks/builder-jammy-tiny --env BP_MAVEN_ACTIVE_PROFILES=native --env "BP_JVM_VERSION=21"
or
pack build rest-api-java-buildpacknative --path .\ --builder paketobuildpacks/builder-jammy-tiny --buildpack paketo-buildpacks/java-native-image --env "BP_JVM_VERSION=21" --env BP_MAVEN_ACTIVE_PROFILES=native
both leads to the error stack above. Targeting JDK 17 vs 21 results in the same error.
Using the default
--builder paketobuildpacks/builder:tiny
seems to indicate that JDK Native 21 isn't supported yet:no valid dependencies for native-image-svm, 21, and io.paketo.stacks.tiny in [(jdk, 8.0.372, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 8.0.372, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 11.0.19, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (native-image-svm, 17.0.7, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jdk, 20.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *]) (jre, 20.0.1, [io.buildpacks.stacks.bionic io.paketo.stacks.tiny *])]
Output of
uname -a
orver
Windows 11
Output of
java -version
liberica 21.0.3-12
Mandrel or GraalVM version (if different from Java)
Oracle GraalVM 21.0.3+7.1 (build 21.0.3+7-LTS-jvmci-23.1-b37)
Quarkus version or git rev
3.12.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)3.9.7 (via Scoop)
Additional information
pom.xml: