3

I am running a simple Java application (just a REST endpoint, a "Hello" response - exactly the example generated by the Quarkus maven archetype, without modification) with the following stack:

  • Quarkus (MicroProfile)
  • JDK 1.8 HotSpot 1.8.0_231-b11
  • GraalVM 19.3.0 (native-image)
  • MacOS Catalina

The first error it is (although it does'nt seems to be the main problem):

[code-with-quarkus-1.0.0-SNAPSHOT-runner:1868]        setup:   8,524.65 ms
java.lang.NoSuchMethodException: com.oracle.svm.core.jdk.LocalizationSupport.addBundleToCache(java.lang.String)
    at java.lang.Class.getDeclaredMethod(Class.java:2130)
    at io.quarkus.runner.AutoFeature.beforeAnalysis(AutoFeature.zig:744)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$7(NativeImageGenerator.java:669)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:669)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
    at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
20:17:42,508 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final
[code-with-quarkus-1.0.0-SNAPSHOT-runner:1868]   (typeflow):  34,257.18 ms
[code-with-quarkus-1.0.0-SNAPSHOT-runner:1868]    (objects):  19,361.86 ms
[code-with-quarkus-1.0.0-SNAPSHOT-runner:1868]   (features):     866.06 ms
[code-with-quarkus-1.0.0-SNAPSHOT-runner:1868]     analysis:  56,364.44 ms

The real problem (I think) it is here:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of java.net.Inet4Address are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use -H:+TraceClassInitialization.
Detailed message:
Trace:
    at parsing org.wildfly.common.net.CidrAddress.<clinit>(CidrAddress.java:46)
Call path from entry point to org.wildfly.common.net.CidrAddress.<clinit>():
    no path found from entry point to target method

So, the first thing I tried was to instruct that the class org.wildfly.common.net.CidrAddress don't be initialized at Image BuildTime, rather initialized at the Image RunTime, with the configuration:

quarkus.native.additional-build-args=--initialize-at-run-time=org.wildfly.common.net.CidrAddress
quarkus.native.enable-jni=true 

But, nothing changes. I also tried to activate (as instructed) the parameter -H:+TraceClassInitialization, to find out what class is being initialized that could be causing the problem. No effect! It doesn't make any difference with this parameter (no extra info).

Did someone else go through this scenario? Any hints, ideas?

Thanks!

Ualter Jr.
  • 2,320
  • 1
  • 25
  • 28

2 Answers2

4

GraalVM 19.3.0 is not supported by Quarkus yet, it was just released and it will need some changes.

In particular you're hitting this problem: - https://github.com/quarkusio/quarkus/pull/5353

I expect GraalVM 19.3 to be supported by Quarkus 1.1, but I'm not sure.

Sanne
  • 6,027
  • 19
  • 34
  • Thanks, @Sanne, the problem was really the incompatible versions (Quarkus 1.0 vs. GraalVM 19.3.0), changing GraalVM to version 19.2.1, it worked perfected! – Ualter Jr. Nov 24 '19 at 15:36
0

I had the same problem with my multistage build:

First I modified my pom.xml:

          <build>
            <plugins>
                <plugin>
                    <groupId>io.quarkus</groupId>
                    <artifactId>quarkus-maven-plugin</artifactId>
                    <version>${quarkus.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>native-image</goal>
                            </goals>
                            <configuration>
                                <enableHttpUrlHandler>true</enableHttpUrlHandler>
                                <enableHttpsUrlHandler>true</enableHttpsUrlHandler>
                                <enableJni>true</enableJni>
                                <additionalBuildArgs>--initialize-at-run-time=java.net.Inet6Address -H:+TraceClassInitialization</additionalBuildArgs>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

Still the same error...

Then I changed the base image of my Dockerfile from FROM quay.io/quarkus/centos-quarkus-maven:19.3.0-java8 AS build to FROM quay.io/quarkus/centos-quarkus-maven:19.2.1 AS build Here is my complete Dockerfile.multistage:

FROM quay.io/quarkus/centos-quarkus-maven:19.2.1 AS build
COPY src /usr/src/app/src
COPY pom.xml /usr/src/app/pom.xml
USER root
RUN chown -R quarkus /usr/src/app
USER quarkus
RUN mvn -f /usr/src/app/pom.xml -Pnative clean package

## Stage 2 : create the docker final image
FROM registry.access.redhat.com/ubi8/ubi-minimal
WORKDIR /work/
COPY --from=build /usr/src/app/target/*-runner /work/application
RUN chmod 775 /work
EXPOSE 8080
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Kostadinov
  • 71
  • 7
  • Thank you for answer, but actually I am not (still) generating a Docker Image, I am still one step before, I just want the Native (executable file) generated locally, not the Docker Image, so I don´t think the Dockerfile plays any role on this problem (at least mine), the command is: mvn package -Pnative (nothing regarding Dockerfile). Anyway, thanks! – Ualter Jr. Nov 24 '19 at 11:09
  • 1
    Check your GRAALVM version with $GRAALVM_HOME/bin/lli --version , if it is 19.3.0, switching to 19.2.1 may help. If you are using https, ssl, you might want to take a look at this one too: https://github.com/quarkusio/quarkus/issues/2125 Lost an hour of my life there... – Kostadinov Nov 24 '19 at 13:53
  • Thanks, @NikolayKostadinov, as also explained by Sanne, the problem is the version, Quarkus 1.0 it nos ready for GraalVM 19.3.0, changing GraalVM to version 19.2.1, it worked perfected! Cheers. – Ualter Jr. Nov 24 '19 at 15:34