quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Native image build failures on latest GraalVM with Random/SplittableRandom initialized at build time #14904

Closed zakkak closed 3 years ago

zakkak commented 3 years ago

Describe the bug Quarkus TS fail with latest Graal (see https://github.com/oracle/graal/actions/runs/546718036)

In the upcoming release of GraalVM (21.1) instances of Random/SplittableRandom class won't be allowed in the native image heap. The corresponding patch can be seen here.

As a result, moving forward Quarkus needs to ensure that its core and extensions reinitialize any classes holding instances of Random/SplittableRandom class.

In order to find out which classes to reinitialize one needs to run:

./mvnw verify \
  -Dnative \
  -Dquarkus.native.additional-build-args="--trace-object-instantiation=java.security.SecureRandom" \
  -pl integration-tests/main

This will print out something like this:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  Object has been initialized by the org.apache.http.impl.auth.NTLMEngineImpl class initializer with a trace: 
        at java.security.SecureRandom.<init>(SecureRandom.java:323)
        at java.security.SecureRandom.getInstance(SecureRandom.java:383)
        at org.apache.http.impl.auth.NTLMEngineImpl.<clinit>(NTLMEngineImpl.java:103)
. Try avoiding to initialize the class that caused initialization of the object. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace: 
        at parsing org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
Call path from entry point to org.apache.http.impl.auth.NTLMEngineImpl.access$000(): 
        at org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
        at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1505)
        at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1474)
        at org.apache.http.impl.auth.NTLMEngineImpl.getType3Message(NTLMEngineImpl.java:181)
        at org.apache.http.impl.auth.NTLMEngineImpl.generateType3Msg(NTLMEngineImpl.java:2097)
        at org.apache.http.impl.auth.NTLMScheme.authenticate(NTLMScheme.java:142)
        at org.apache.http.impl.auth.AuthSchemeBase.authenticate(AuthSchemeBase.java:136)
        at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:233)
        at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:213)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
        at org.jboss.resteasy.client.jaxrs.engines.ManualClosingApacheHttpClient43Engine.invoke(ManualClosingApacheHttpClient43Engine.java:268)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:488)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.lambda$executorSubmit$11(ClientInvocation.java:770)
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation$$Lambda$2014/0x00000007c4cd7840.get(Unknown Source)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:211)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:164)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:293)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

Which indicates that Quarkus should reinitialize NTLMEngineImpl at runtime.

Expected behavior Tests should pass (at least most of them)

Actual behavior Multiple integration tests fail.

To Reproduce

  1. Build GraalVM master with: mx --primary-suite-path substratevm --components='Native Image' build
  2. export GRAALVM_HOME=/path/to/graal/sdk/latest_graalvm_home
  3. ./mvnw clean verify -Dnative -Dnative.surefire.skip -pl integration-tests/main

Environment (please complete the following information):

jerboaa commented 3 years ago

For reference, instead of building Graal VM master from source, one could also use 21.1 dev builds from: https://github.com/graalvm/graalvm-ce-dev-builds/releases in order to reproduce those failures.

jerboaa commented 3 years ago

PR for solving the runtime-init problem for modules using http-client (includes integration-test/main): https://github.com/quarkusio/quarkus/pull/15856

jerboaa commented 3 years ago

PR for integration-tests/redis-client: https://github.com/quarkusio/quarkus/pull/15864

jerboaa commented 3 years ago

PR for integration-tests/reactive-messaging-kafka: https://github.com/quarkusio/quarkus/pull/15879

galderz commented 3 years ago

I've created #15889 to track the quarkus-integration-test-bouncycastle-fips failures. It needs some consideration and agreement on the solution.

jerboaa commented 3 years ago

Elytron Security LDAP is actually a Graal issue: https://github.com/oracle/graal/issues/3297

jerboaa commented 3 years ago

PR for integration-tests/amazon-services: https://github.com/quarkusio/quarkus/pull/15897

jerboaa commented 3 years ago

PR for integration-tests/artemis-core and integration-tests/artemis-jms: https://github.com/quarkusio/quarkus/pull/15952

jerboaa commented 3 years ago

At this point most of the Random/SplittableRandom related failures should be fixed. I haven't done a full run, but it would be good to get one done with quarkus master to see what's still left. @zakkak could you help with that?

zakkak commented 3 years ago

@zakkak could you help with that?

Sure, I started https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/681073992 to test latest Quarkus with latest GraalVM.

jerboaa commented 3 years ago

@zakkak Thanks. In the spirit of teach a man to fish, what would be the steps to do this myself? Anyway, most issues are now #15962 which is unfortunate since we still have lots of noise :(

zakkak commented 3 years ago

@zakkak Thanks. In the spirit of teach a man to fish, what would be the steps to do this myself?

In that case I just copied the GH workflow from oracle/graal to a new repo (zakkak/graalvm-quarkus-ci) and slightly edited it to use the latest dev branch of both graalvm and quarkus (the original workflow is using the latest release of quarkus with the latest dev branch of graalvm).

I also made it possible to trigger the workflow on demand with different combinations of versions and repos as well. It would be nice to have the option to use forked repos as well to try out PRs as well. image I probably need to give you (and anyone interested in running this kind of tests) some access rights to the repo.

Anyway, most issues are now #15962 which is unfortunate since we still have lots of noise :(

True, #15962 seems to be something new though , so I'll try to schedule a run with an older version to see how far we have gone with the Random/SplittableRandom related failures. I started a new workflow to test @geoand 's fix for #15962 with latest graalvm: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683208450

jerboaa commented 3 years ago

@zakkak Thanks for the info!

zakkak commented 3 years ago

Job for latest Quarkus vs latest Graal now that #15962 is fixed: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199

geoand commented 3 years ago

👍🏼

jerboaa commented 3 years ago

Job for latest Quarkus vs latest Graal now that #15962 is fixed: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199

Now that looks a lot better already! Thank you.

zakkak commented 3 years ago

I list below the ITs that are still failing (based on https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/683707199)

Random/SplitRandom related

  1. Bouncy Castle FIPS
  2. Elytron Security LDAP
  3. JGit
  4. Spring Data JPA
  5. gRPC - TLS
  6. gRPC - Plain Text with gzip compression
  7. gRPC - Plain Text with Mutiny
  8. gRPC - TLS with mutual auth
  9. gRPC - Interceptors
  10. gRPC - Proto v2

Other

  1. Bouncy Castle JSEE Compiles but fails with:

    java.lang.NoSuchMethodException: org.bouncycastle.jcajce.provider.drbg.DRBG$Default.<init>(java.security.SecureRandomParameters)
  2. Kafka with Snappy Compiles but fails with:

    ERROR: Failed to start application (with profile prod)
    org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=x86_64
    at io.quarkus.kafka.client.runtime.KafkaRecorder.loadSnappy(KafkaRecorder.java:39)
    at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy_0(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:67)
    at io.quarkus.deployment.steps.KafkaProcessor$loadSnappyIfEnabled1534179476.deploy(KafkaProcessor$loadSnappyIfEnabled1534179476.zig:40)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:400)
    at io.quarkus.runtime.Application.start(Application.java:90)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
    at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
zakkak commented 3 years ago

PR for gRPC* tests https://github.com/quarkusio/quarkus/pull/16008

jerboaa commented 3 years ago

@zakkak

  1. Elytron Security LDAP is oracle/graal#3297
  2. JGit seems a bytecode parsing problem (not j.u.Random related). Probably a graal issue.
  3. Bouncy Castle FIPS is tracked with https://github.com/quarkusio/quarkus/issues/15889
  4. Spring Data JPA seems to the only one left after #16008
jerboaa commented 3 years ago

I'll look into Spring Data JPA

zakkak commented 3 years ago
2. JGit seems a bytecode parsing problem (not j.u.Random related). Probably a graal issue.

Hmm I just saw that as well, but it seems non-deterministic... I'll see if I can get a reproducer. In the meantime https://github.com/quarkusio/quarkus/pull/16017 fixes the Random related issue for it.

gsmet commented 3 years ago

@zakkak @jerboaa I just wanted to thank you both for this work!

gsmet commented 3 years ago

@jerboaa I'm surprised Spring Data JPA is an issue. We're supposed to only use a subset of Spring Data JPA APIs and no implementations.

geoand commented 3 years ago

What is the issue with Spring Data JPA?

jerboaa commented 3 years ago

@gsmet @geoand https://github.com/quarkusio/quarkus/issues/16018 is the Spring Data JPA issue.

jerboaa commented 3 years ago
2. JGit seems a bytecode parsing problem (not j.u.Random related). Probably a graal issue.

Hmm I just saw that as well, but it seems non-deterministic... I'll see if I can get a reproducer.

Indeed seems to be non-deterministic :( Thanks for fixing the j.u.Random issues.

jerboaa commented 3 years ago

Latest test run with graal master and quarkus master here: https://github.com/zakkak/graalvm-quarkus-ci/actions/runs/687103625

jerboaa commented 3 years ago
2. JGit seems a bytecode parsing problem (not j.u.Random related). Probably a graal issue.

Hmm I just saw that as well, but it seems non-deterministic... I'll see if I can get a reproducer.

Indeed seems to be non-deterministic :( Thanks for fixing the j.u.Random issues.

I've created this issue to track it: https://github.com/graalvm/mandrel/issues/226

jerboaa commented 3 years ago

I believe we've covered all the bases for Random/SplittableRandom now and this umbrella issue can be closed. What remains are other issues (or non-quarkus issues):

  1. Bouncy Castle FIPS is tracked with #15889
  2. jgit bytecode parsing issue (intermittent). Tracked with graalvm/mandrel#226
  3. Elytron Security LDAP is oracle/graal#3297
  4. Kafka with snappy. Native lib fails to load. Tracked with #16042
gsmet commented 3 years ago

Thanks for your work!

zakkak commented 3 years ago

Thank you @jerboaa!

akuzni2 commented 3 years ago

I'm getting this error when converting one of my applications to Quarkus to build a native-image using GraalVM 21.1.0. From this thread I can't really tell what I need to do to get around it.

I'm building my quarkus project with Quarkus 1.13.4.Final

galderz commented 3 years ago

@akuzni2 I might be wrong but I think 21.1 is only supported in Quarkus 2.x onwards...

zakkak commented 3 years ago

@akuzni2 I might be wrong but I think 21.1 is only supported in Quarkus 2.x onwards...

That's correct,

Quarkus version Compatible GraalVM/Mandrel version
1.12.x 21.0.x.x
1.13.x 20.3.x.x
21.0.x.x
2.0.x 20.3.x.x
21.1.x.x

source: https://github.com/graalvm/mandrel/wiki

dufoli commented 3 years ago

hello,

I have same issue on cxf extension. https://github.com/quarkiverse/quarkus-cxf/pull/253 it failed with exception. Can you help with that because I am not sure. Do I need to switch to runtime initialization for some class : org.apache.cxf.endpoint.ClientImpl

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

com.oracle.svm.core.util.UserError$UserException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

at com.oracle.svm.core.util.UserError.abort(UserError.java:82)
at com.oracle.svm.hosted.FallbackFeature.reportAsFallback(FallbackFeature.java:233)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:798)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:582)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
Call path from entry point to org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue():
at org.apache.cxf.attachment.AttachmentUtil.getUniqueBoundaryValue(AttachmentUtil.java:255)
at org.apache.cxf.attachment.AttachmentSerializer.writeProlog(AttachmentSerializer.java:82)
at org.apache.cxf.interceptor.AttachmentOutInterceptor.handleMessage(AttachmentOutInterceptor.java:91)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:831)
at org.apache.cxf.endpoint.ClientImpl$3$1.run(ClientImpl.java:923)
at java.lang.Thread.run(Thread.java:829)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

at com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:126)
at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:795)
... 8 more
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point.
at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.error(DisallowedImageHeapObjectFeature.java:163)
at com.oracle.svm.core.image.DisallowedImageHeapObjects.check(DisallowedImageHeapObjects.java:65)
at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.replacer(DisallowedImageHeapObjectFeature.java:139)
at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:565)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:213)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:184)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readValue(AnalysisConstantReflectionProvider.java:98)
at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.readFieldValue(AnalysisConstantReflectionProvider.java:77)
at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.util.ConstantFoldUtil$1.readValue(ConstantFoldUtil.java:51)
at jdk.internal.vm.compiler/org.graalvm.compiler.core.common.spi.JavaConstantFieldProvider.readConstantField(JavaConstantFieldProvider.java:84)
at com.oracle.svm.hosted.ameta.AnalysisConstantFieldProvider.readConstantField(AnalysisConstantFieldProvider.java:70)
at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.util.ConstantFoldUtil.tryConstantFold(ConstantFoldUtil.java:47)
at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.tryConstantFold(ConstantFoldLoadFieldPlugin.java:61)
at com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin.handleLoadStaticField(ConstantFoldLoadFieldPlugin.java:57)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4972)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genGetStatic(BytecodeParser.java:4939)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5442)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3451)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3258)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1125)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1019)
at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:84)
at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:76)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:212)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
at com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:113)
at com.oracle.svm.hosted.SVMHost.parseBytecode(SVMHost.java:647)
at com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:592)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:163)
at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:304)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.createTypeFlow(MethodTypeFlow.java:313)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureTypeFlowCreated(MethodTypeFlow.java:302)
at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
at com.oracle.graal.pointsto.flow.StaticInvokeTypeFlow.update(InvokeTypeFlow.java:420)
at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:547)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
zakkak commented 3 years ago

Hi @dufoli, my understanding is that https://github.com/quarkiverse/quarkus-cxf/commit/8804ddad2bee27311d63f33d2ec6d2befde2dc8f fixed the above issue, is that right?

dufoli commented 3 years ago

@zakkak yes

akuzni2 commented 3 years ago

HI @zakkak @dufoli thanks for commenting back. I've upgraded to Quarkus 2.0.0 and I still see the same issue cause by some AWS dependencies.

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by 
        reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of
                constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@546fe072 reached by 
        reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of
                constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@4d11ec9e reached by 
        reading field com.amazonaws.retry.RetryPolicy.backoffStrategy of
                constant com.amazonaws.retry.RetryPolicy@28b37dae reached by 
        scanning method com.amazonaws.ClientConfiguration.<init>(ClientConfiguration.java:155)
Call path from entry point to com.amazonaws.ClientConfiguration.<init>(ClientConfiguration): 
        at com.amazonaws.ClientConfiguration.<init>(ClientConfiguration.java:378)
        at com.amazonaws.client.builder.AwsClientBuilder.resolveClientConfiguration(AwsClientBuilder.java:169)
        at com.amazonaws.client.builder.AwsClientBuilder.access$000(AwsClientBuilder.java:54)
        at com.amazonaws.client.builder.AwsClientBuilder$SyncBuilderParams.<init>(AwsClientBuilder.java:505)
        at com.amazonaws.client.builder.AwsClientBuilder.getSyncClientParams(AwsClientBuilder.java:441)
        at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
        at com.mycompany.service.ApiServiceImpl.<init>(ApiServiceImpl.java:23)
        at com.mycompany.service.ProcessingService.<init>(ProcessingService.java:22)
        at com.mycompany.service.ProcessingService_Bean.create(ProcessingService_Bean.zig:140)
        at com.mycompany.service.ProcessingService_Bean.create(ProcessingService_Bean.zig:155)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.initializeLazyValue(SystemPropertiesSupport.java:216)
        at com.oracle.svm.core.jdk.SystemPropertiesSupport.getProperty(SystemPropertiesSupport.java:169)
        at com.oracle.svm.core.jdk.Target_java_lang_System.getProperty(JavaLangSubstitutions.java:291)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_System_2_0002egetProperty_00028Ljava_lang_String_2_00029Ljava_lang_String_2(generated:0)

I'm not really sure how to perform the recommendation by the error message

Or you can write your own initialization methods and call them explicitly from your main entry point.

If you have any ideas please let me know.

dufoli commented 3 years ago

@akuzni2 what aws extension are you using ? do you add the corresponding quarkus extension ? s3, lambda, SNS, SQS, ... ?

wsy89 commented 3 years ago

@dufoli I am getting exactly the same issue as @akuzni2 is getting when I try to invoke another lamba using

@Produces
@ApplicationScoped
public AWSLambda awsLambda() {
    return AWSLambdaAsyncClient.builder().build();
}
<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-lambda</artifactId>
    <version>1.12.15</version>
</dependency>
EdwinKorsten commented 3 years ago

I have the same problem as @wsy89 and @akuzni2 with an AWS SDK library.

Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=. Or you can write your own initialization methods and call them explicitly from your main entry point. Trace: Object was reached by reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@5c3fa02c reached by reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@42c1d66e reached by reading field com.amazonaws.retry.RetryPolicy.backoffStrategy of constant com.amazonaws.retry.RetryPolicy@35cbe86 reached by scanning method com.amazonaws.ClientConfiguration.(ClientConfiguration.java:74) Call path from entry point to com.amazonaws.ClientConfiguration.(): no path found from entry point to target method

Adding this to maven does not help:

--initialize-at-run-time=com.amazonaws.ClientConfiguration\,com.amazonaws.retry.PredefinedBackoffStrategies
wsy89 commented 3 years ago

@EdwinKorsten @akuzni2 I was able to fix this by adding

--initialize-at-run-time=org.apache.http.impl.auth.NTLMEngineImpl

in additional build arg. Also I had to use aws sdk v2 instead of v1

antonwiens commented 3 years ago

@gsmet I am running also into the issue with org.apache.http.impl.auth.NTLMEngineImpl using aws s3 extension and apache client. Can we get a fix for that?

jerboaa commented 3 years ago

@antonwiens Are you also using the HTTP client extension as a dependency as described here?

https://quarkus.io/guides/amazon-s3#configuring-s3-clients

antonwiens commented 3 years ago

@jerboaa No, i didn't. I pulled up the versions and didn`t know i had to add this, thats a nice hint, thanks and sorry for pulling this issue up again.

Maybe a build error from the quarkus plugin would be nice, if the apache client dependency was added and the quarkus-apache-client extension was missing. Just as a hint for ppl upgrading or not reading the documentation properly :)

jmgtan commented 2 years ago

I've been getting the same Random/SplittableRandom error. I'm currently following the Quarkus Lambda guide (https://quarkus.io/guides/amazon-lambda) using the Quarkus 2.7.3.Final with GraalVM 21.3.1. I'm using the DynamoDB client from Java SDK v2.

Update: managed to get it to work by following the sample code found here: https://github.com/quarkusio/quarkus-quickstarts/blob/main/amazon-dynamodb-quickstart/pom.xml. Specifically by the use of the quarkus-amazon-dynamodb dependency instead of including the AWS SDK directly. I don't see this mentioned in any of the guides. Working now and man is the Lambda function fast! Great work.

galderz commented 2 years ago

@jmgtan Maybe you could improve the amazon-lambda guide? OSS FTW

MarkusKramer commented 2 years ago

@jmgtan I've also started hitting the Random/SplittableRandom error with the latest AWS SDK. It is possible to workaround it by using --initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier. see https://github.com/aws/aws-sdk-java-v2/issues/3323

gsmet commented 2 years ago

@MarkusKramer I created https://github.com/quarkiverse/quarkus-amazon-services/pull/220 to fix the issue in our extension.