Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraalVM 21.2.0 + Java 16 - Native build fails #3226

Closed
llowinge opened this issue Oct 25, 2021 · 11 comments
Closed

GraalVM 21.2.0 + Java 16 - Native build fails #3226

llowinge opened this issue Oct 25, 2021 · 11 comments

Comments

@llowinge
Copy link
Contributor

llowinge commented Oct 25, 2021

I can see following error (running eg. any integration test in Native mode) using GraalVM 21.2.0 + JDK 16 (with JDK 11 it works great).

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 21.2.0 Java 16 CE (Java Version 16.0.2+7-jvmci-21.2-b08)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] /Users/llowinge/.sdkman/candidates/java/21.2.0.r16-grl/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=CZ -J-Dfile.encoding=UTF-8 -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace -H:-ParseOnce camel-quarkus-examples-file-bindy-ftp-2.2.0-SNAPSHOT-runner -jar camel-quarkus-examples-file-bindy-ftp-2.2.0-SNAPSHOT-runner.jar
[camel-quarkus-examples-file-bindy-ftp-2.2.0-SNAPSHOT-runner:16830]    classlist:   2,415.44 ms,  1.19 GB
[camel-quarkus-examples-file-bindy-ftp-2.2.0-SNAPSHOT-runner:16830]        setup:   1,025.59 ms,  1.19 GB
Error: could not find target field: private static org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansWeakCache org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansIntrospector.declaredMethodCache
com.oracle.svm.core.util.UserError$UserException: could not find target field: private static org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansWeakCache org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansIntrospector.declaredMethodCache
        at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
        at com.oracle.svm.core.util.UserError.guarantee(UserError.java:96)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findOriginalField(AnnotationSubstitutionProcessor.java:780)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleFieldInAliasClass(AnnotationSubstitutionProcessor.java:440)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleAliasClass(AnnotationSubstitutionProcessor.java:344)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:310)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:266)
        at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:936)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:868)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:491)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:380)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)

@llowinge llowinge changed the title GraalVM 21.2.0 + Java 16 fails GraalVM 21.2.0 + Java 16 - Native build fails Oct 25, 2021
@zhfeng
Copy link
Contributor

zhfeng commented Oct 25, 2021

It could be related to JEP 403: Strongly Encapsulate JDK Internals
and com.sun.beans.WeakCache is an internal API and can not be used since JDK 16.

@jamesnetherton
Copy link
Contributor

@ppalaga Do you remember the history of the stuff in this package and whether we need it anymore?

https://github.com/apache/camel-quarkus/tree/main/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/runtime/graal

@ffang
Copy link
Contributor

ffang commented Nov 3, 2021

hmm, com.sun.beans.WeakCache should be reflectively accessible until JDK17 by default(JEP 403 take effect since JDK17). So probably this error in JDK16 is something else

@vladimirfx
Copy link
Contributor

Quarkus 2.4.1.Final + GraalVM 21.3.0-java17:

21.3-java17: Pulling from quarkus/ubi-quarkus-native-image
Digest: sha256:05a26d427591c5c614f55b12ec55b6b54b0134b198d226a277d761fb7e1a6d6f
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:21.3-java17
quay.io/quarkus/ubi-quarkus-native-image:21.3-java17
[partner-scoring-service-1.5.0-SNAPSHOT-runner:27]    classlist:   5 182,59 ms,  0,94 GB
[partner-scoring-service-1.5.0-SNAPSHOT-runner:27]        setup:     839,03 ms,  0,94 GB
Error: could not find target field: private static org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansWeakCache org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansIntrospector.declaredMethodCache
com.oracle.svm.core.util.UserError$UserException: could not find target field: private static org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansWeakCache org.apache.camel.quarkus.support.common.runtime.graal.SubstituteBeansIntrospector.declaredMethodCache
        at com.oracle.svm.core.util.UserError.abort(UserError.java:73)
        at com.oracle.svm.core.util.UserError.guarantee(UserError.java:101)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findOriginalField(AnnotationSubstitutionProcessor.java:788)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleFieldInAliasClass(AnnotationSubstitutionProcessor.java:442)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleAliasClass(AnnotationSubstitutionProcessor.java:346)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:310)
        at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:266)
        at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:912)
        at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:839)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:527)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:488)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:569)
[partner-scoring-service-1.5.0-SNAPSHOT-runner:27]      [total]:   6 120,29 ms,  0,94 GB
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:122)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:599)
# Printing build artifacts to: /project/partner-scoring-service-1.5.0-SNAPSHOT-runner.build_artifacts.txt
Error: Image build request failed with exit status 1
Failed to copy native image from container volume back to the host.
Failed to remove volume: quarkus-native-builder-image-project-volume

Should I file a new issue?

@jamesnetherton
Copy link
Contributor

Should I file a new issue?

It's bascially the same issue that was originally reported, so I think it's ok to cover it in this issue.

We need to establish whether this particular substitution is actually needed anymore.

@vladimirfx
Copy link
Contributor

quarkusio/quarkus#2352

I think it is not needed anymore. Moreover, it is not possible to use it anymore. Can I submit the PR removing this subsitution?

@jamesnetherton
Copy link
Contributor

Can I submit the PR removing this subsitution?

Yes, but the slight issue is that we don't yet test multiple GraalVM JDK versions. We just test with whatever the Quarkus default is.

If you can verify locally that removing it causes no issues, then feel free to create a PR.

@vladimirfx
Copy link
Contributor

If you can verify locally that removing it causes no issues, then feel free to create a PR.

Trying to do so for current versions of Graal 21.2 Java 11, Graal 21.3 Java 11 + Java 17.

vladimirfx added a commit to cit-consulting/camel-quarkus that referenced this issue Nov 4, 2021
@vladimirfx
Copy link
Contributor

Please review #3264

@ppalaga
Copy link
Contributor

ppalaga commented Nov 5, 2021

@ppalaga Do you remember the history of the stuff in this package and whether we need it anymore?

https://github.com/apache/camel-quarkus/tree/main/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/runtime/graal

Sorry for coming too late, but I cannot help with any useful knowledge anyway. The last change is from me, but I just moved the classes to another package. The original classes come from the very early days of Camel Quarkus (Aug 1st, 2019!) and are by @lburgazzoli . I agree that we can remove them if a local testing by @vladimirfx (thanks!) is successful.

@lburgazzoli
Copy link
Contributor

I really don't recall the reason for that substitution, it can also be that we have fixed the problem in camel by the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants