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

FireStore problem with native-image #67

Closed
huw0 opened this issue Jan 2, 2021 · 5 comments · Fixed by #71
Closed

FireStore problem with native-image #67

huw0 opened this issue Jan 2, 2021 · 5 comments · Fixed by #71

Comments

@huw0
Copy link

huw0 commented Jan 2, 2021

I'm getting errors generating a native image.

#Quarkus
quarkusPluginId=io.quarkus
quarkusPluginVersion=1.10.5.Final
quarkusPlatformGroupId=io.quarkus
quarkusPlatformArtifactId=quarkus-universe-bom
quarkusPlatformVersion=1.10.5.Final
quarkiverseVersion=0.3.0

Building the native-image with ./gradlew -Dquarkus.package.type=native -Dquarkus.native.container-runtime=podman clean build which uses the container quay.io/quarkus/ubi-quarkus-native-image:20.2.0-java11

Error: Class initialization of io.grpc.alts.ComputeEngineChannelBuilder failed. Use the option --initialize-at-run-time=io.grpc.alts.ComputeEngineChannelBuilder to explicitly request delayed initialization of this class.
Original exception that caused the problem: java.lang.NoClassDefFoundError: io/grpc/netty/shaded/io/grpc/netty/NettyChannelBuilder
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1042)
        at jdk.unsupported/sun.misc.Unsafe.ensureClassInitialized(Unsafe.java:698)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.ensureClassInitialized(ConfigurableClassInitialization.java:177)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:594)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:130)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.maybeInitializeHosted(ConfigurableClassInitialization.java:168)
        at com.oracle.svm.hosted.SVMHost.registerType(SVMHost.java:236)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.createType(AnalysisUniverse.java:271)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:209)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookup(AnalysisUniverse.java:186)
        at com.oracle.graal.pointsto.meta.AnalysisMethod.<init>(AnalysisMethod.java:108)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.createMethod(AnalysisUniverse.java:419)
        at com.oracle.graal.pointsto.meta.AnalysisUniverse.lookupAllowUnresolved(AnalysisUniverse.java:407)
        at com.oracle.graal.pointsto.infrastructure.WrappedConstantPool.lookupMethod(WrappedConstantPool.java:125)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethodInPool(BytecodeParser.java:4313)
        at com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.lookupMethodInPool(SharedGraphBuilderPhase.java:113)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.lookupMethod(BytecodeParser.java:4307)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeStatic(BytecodeParser.java:1622)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5340)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3413)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3220)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1090)
        at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:984)
        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:74)
        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:214)
        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.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:223)
        at com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:357)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.doParse(MethodTypeFlow.java:313)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureParsed(MethodTypeFlow.java:302)
        at com.oracle.graal.pointsto.flow.MethodTypeFlow.addContext(MethodTypeFlow.java:103)
        at com.oracle.graal.pointsto.DefaultAnalysisPolicy$DefaultSpecialInvokeTypeFlow.onObservedUpdate(DefaultAnalysisPolicy.java:368)
        at com.oracle.graal.pointsto.flow.TypeFlow.notifyObservers(TypeFlow.java:470)
        at com.oracle.graal.pointsto.flow.TypeFlow.update(TypeFlow.java:542)
        at com.oracle.graal.pointsto.BigBang$2.run(BigBang.java:552)
        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)
        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: java.lang.ClassNotFoundException: io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 46 more
Error: No instances of sun.security.provider.NativePRNG 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.
Trace: Object was reached by 
        reading field java.security.SecureRandom.secureRandomSpi of
                constant java.security.SecureRandom@383e8d4 reached by 
        scanning method com.google.cloud.firestore.FirestoreImpl.autoId(FirestoreImpl.java:86)
Call path from entry point to com.google.cloud.firestore.FirestoreImpl.autoId(): 
        at com.google.cloud.firestore.FirestoreImpl.autoId(FirestoreImpl.java:83)
        at com.google.cloud.firestore.CollectionReference.document(CollectionReference.java:100)
        at com.google.cloud.firestore.CollectionReference.add(CollectionReference.java:187)
        at com.google.cloud.firestore.CollectionReference.add(CollectionReference.java:215)

Haven't had any time yet to look any further.

@loicmathieu
Copy link
Collaborator

Hi,
Can you give us the list of extensions you use ?
From the features listed when you start your application or from your pom.xml ?

The netty-shadded library should not be included by the firestore extension so there may be some dependency issues.

@loicmathieu
Copy link
Collaborator

Same issue as #69 I think, you can use the same workaround of adding the pubsub library.
I'll work on a fix for the next release.

@huw0
Copy link
Author

huw0 commented Jan 9, 2021

Thanks for your quick response @loicmathieu . I can confirm that the pubsub workaround fixes the netty stack. However the second stack around SecureRandom / NativePRNG remains.

@huw0
Copy link
Author

huw0 commented Jan 9, 2021

Based on oracle/graal#712 I tried quarkus.native.additional-build-args=--rerun-class-initialization-at-runtime=com.google.cloud.firestore.FirestoreImpl

This or the not deprecated equivalent of quarkus.native.additional-build-args=--initialize-at-run-time=com.google.cloud.firestore.FirestoreImpl gets things building. Haven't yet tested whether this actually works at runtime.

@loicmathieu
Copy link
Collaborator

@huw0 I didn't notice the second stacktrace, sorry.

I tested with master and it works. It'll be OK with the release 0.4

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

Successfully merging a pull request may close this issue.

2 participants