我正在运行一个简单的 Java 应用程序(只是一个 REST 端点,一个“Hello”响应 - 正是 Quarkus maven 原型(prototype)生成的示例,没有修改)具有以下堆栈:
- Quarkus(微文件)
- JDK 1.8 热点 1.8.0_231-b11
- GraalVM 19.3.0(原生图像)
- MacOS Catalina
这是第一个错误(虽然它似乎不是主要问题):
[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
真正的问题(我认为)在这里:
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
因此,我尝试的第一件事是指示类 org.wildfly.common.net.CidrAddress 不要在 Image BuildTime 初始化,而是在 Image RunTime 初始化,配置如下:
quarkus.native.additional-build-args=--initialize-at-run-time=org.wildfly.common.net.CidrAddress
quarkus.native.enable-jni=true
但是,什么都没有改变。我还尝试激活(按照指示)参数 -H:+TraceClassInitialization,以找出可能导致问题的正在初始化的类。没有效果!它与此参数没有任何区别(无额外信息)。
其他人是否经历过这种情况?任何提示,想法?
谢谢!
最佳答案
Quarkus 尚不支持 GraalVM 19.3.0,它刚刚发布,需要进行一些更改。
特别是你遇到了这个问题: - https://github.com/quarkusio/quarkus/pull/5353
我希望 Quarkus 1.1 支持 GraalVM 19.3,但我不确定。
关于quarkus - 图像堆中不允许...的实例,因为此类应在图像运行时初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59011565/