Graal: [native-image] Failed to compile hazelcast release

Created on 19 Jul 2019  路  5Comments  路  Source: oracle/graal

Running the Dockerfile below to try to build the latest hazelcast (3.12.1) with the latest native-image (19.1.1) fails with a bunch of UnresolvedElementExceptions:

Step 7/8 : RUN native-image -jar hazelcast-all-${hazelcast_version}.jar
 ---> Running in 148308ec2ab1
Build on Server(pid: 28, port: 41375)*
[hazelcast-all-3.12.1:28]    classlist:   4,024.45 ms
[hazelcast-all-3.12.1:28]        (cap):     987.84 ms
[hazelcast-all-3.12.1:28]        setup:   2,266.05 ms
[hazelcast-all-3.12.1:28]     analysis:  17,967.66 ms
Warning: Aborting stand-alone image build. Unsupported features in 4 methods
Detailed message:
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.hazelcast.cache.impl.AbstractCacheService.getEventJournal(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
    at parsing com.hazelcast.ringbuffer.impl.operations.MergeOperation.getRingbufferConfig(MergeOperation.java:208)
Call path from entry point to com.hazelcast.ringbuffer.impl.operations.MergeOperation.getRingbufferConfig(RingbufferService, ObjectNamespace):
    at com.hazelcast.ringbuffer.impl.operations.MergeOperation.getRingbufferConfig(MergeOperation.java:198)
    at com.hazelcast.ringbuffer.impl.operations.MergeOperation.beforeRun(MergeOperation.java:85)
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:197)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:147)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:125)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:110)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
    at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.hazelcast.cache.impl.AbstractCacheService.getEventJournal(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
    at parsing com.hazelcast.ringbuffer.impl.operations.ReplicationOperation.getRingbufferConfig(ReplicationOperation.java:93)
Call path from entry point to com.hazelcast.ringbuffer.impl.operations.ReplicationOperation.getRingbufferConfig(RingbufferService, ObjectNamespace):
    at com.hazelcast.ringbuffer.impl.operations.ReplicationOperation.getRingbufferConfig(ReplicationOperation.java:83)
    at com.hazelcast.ringbuffer.impl.operations.ReplicationOperation.run(ReplicationOperation.java:63)
    at com.hazelcast.spi.Operation.call(Operation.java:170)
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.call(OperationRunnerImpl.java:210)
    at com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:199)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:147)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:125)
    at com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:110)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
    at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: com.hazelcast.internal.management.request.GetCacheEntryRequest.<init>(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace:
    at parsing com.hazelcast.internal.management.ManagementCenterService$TaskPollThread.<init>(ManagementCenterService.java:590)
Call path from entry point to com.hazelcast.internal.management.ManagementCenterService$TaskPollThread.<init>(ManagementCenterService):
    at com.hazelcast.internal.management.ManagementCenterService$TaskPollThread.<init>(ManagementCenterService.java:582)
    at com.hazelcast.internal.management.ManagementCenterService.<init>(ManagementCenterService.java:136)
    at com.hazelcast.instance.Node.start(Node.java:452)
    at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:136)
    at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:228)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:207)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:157)
    at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:91)
    at com.hazelcast.core.server.StartServer.main(StartServer.java:46)
    at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:147)
    at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: javax.cache.CacheException. To diagnose the issue you can use the --allow-incomplete-classpath option. The missing type is then reported at run time when it is accessed the first time.
Trace:
    at parsing com.hazelcast.client.impl.protocol.ClientExceptions.<init>(ClientExceptions.java:117)
Call path from entry point to com.hazelcast.client.impl.protocol.ClientExceptions.<init>(boolean):
    at com.hazelcast.client.impl.protocol.ClientExceptions.<init>(ClientExceptions.java:115)
    at com.hazelcast.client.impl.ClientEngineImpl.initClientExceptionFactory(ClientEngineImpl.java:169)
    at com.hazelcast.client.impl.ClientEngineImpl.<init>(ClientEngineImpl.java:161)
    at com.hazelcast.instance.Node.<init>(Node.java:250)
    at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:161)
    at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:131)
    at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:228)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:207)
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:157)
    at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:91)
    at com.hazelcast.core.server.StartServer.main(StartServer.java:46)
    at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:147)
    at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(generated:0)

Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Build on Server(pid: 28, port: 41375)
[hazelcast-all-3.12.1:28]    classlist:     183.93 ms
[hazelcast-all-3.12.1:28]        (cap):     551.17 ms
[hazelcast-all-3.12.1:28]        setup:     896.52 ms
[hazelcast-all-3.12.1:28]   (typeflow):   1,626.24 ms
[hazelcast-all-3.12.1:28]    (objects):   1,486.93 ms
[hazelcast-all-3.12.1:28]   (features):     137.21 ms
[hazelcast-all-3.12.1:28]     analysis:   3,333.33 ms
[hazelcast-all-3.12.1:28]     (clinit):     106.19 ms
[hazelcast-all-3.12.1:28]     universe:     302.06 ms
[hazelcast-all-3.12.1:28]      (parse):     418.86 ms
[hazelcast-all-3.12.1:28]     (inline):     948.93 ms
[hazelcast-all-3.12.1:28]    (compile):   3,986.91 ms
[hazelcast-all-3.12.1:28]      compile:   5,686.20 ms
[hazelcast-all-3.12.1:28]        image:     325.92 ms
[hazelcast-all-3.12.1:28]        write:     131.60 ms
[hazelcast-all-3.12.1:28]      [total]:  10,930.90 ms
Warning: Image 'hazelcast-all-3.12.1' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation).

To reproduce run docker build using this Dockerfile:

FROM oracle/graalvm-ce:latest AS builder

ARG hazelcast_version=3.12.1

RUN gu install native-image
RUN yum -y install wget

WORKDIR /cp

RUN wget -q -c https://repo1.maven.org/maven2/com/hazelcast/hazelcast-all/${hazelcast_version}/hazelcast-all-${hazelcast_version}.jar

RUN native-image -jar hazelcast-all-${hazelcast_version}.jar

RUN mv hazelcast-all-${hazelcast_version} hazelcast

If we further add --allow-incomplete-classpath to the native-image invocation, we get different errors ("Class XXX cannot be instantiated reflectively . It does not have a nullary constructor")

Step 7/8 : RUN native-image -jar hazelcast-all-${hazelcast_version}.jar --allow-incomplete-classpath
 ---> Running in 315b0eea8e8b
Build on Server(pid: 28, port: 38641)*
[hazelcast-all-3.12.1:28]    classlist:   4,557.25 ms
[hazelcast-all-3.12.1:28]        (cap):     867.61 ms
[hazelcast-all-3.12.1:28]        setup:   2,113.71 ms
[hazelcast-all-3.12.1:28]     analysis:  18,441.22 ms
Fatal error: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Class com.hazelcast.instance.DefaultNodeExtension cannot be instantiated reflectively . It does not have a nullary constructor.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
    at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
    at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:457)
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:308)
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:446)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.executeCompilation(NativeImageBuildServer.java:394)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$processCommand$8(NativeImageBuildServer.java:331)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.withJVMContext(NativeImageBuildServer.java:412)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.processCommand(NativeImageBuildServer.java:328)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.processRequest(NativeImageBuildServer.java:272)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$serve$7(NativeImageBuildServer.java:232)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Class com.hazelcast.instance.DefaultNodeExtension cannot be instantiated reflectively . It does not have a nullary constructor.
    at org.graalvm.nativeimage.hosted.RuntimeReflection.registerForReflectiveInstantiation(RuntimeReflection.java:127)
    at com.oracle.svm.hosted.ServiceLoaderFeature.handleType(ServiceLoaderFeature.java:222)
    at com.oracle.svm.hosted.ServiceLoaderFeature.duringAnalysis(ServiceLoaderFeature.java:112)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:706)
    at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
    at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:706)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:522)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:440)
    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)
Error: Image build request failed with exit status 1
The command '/bin/sh -c native-image -jar hazelcast-all-${hazelcast_version}.jar --allow-incomplete-classpath' returned a non-zero code: 1
native-image

Most helpful comment

The underlying problem is that com.hazelcast.instance.DefaultNodeExtension should provide a nullary constructor because it is registered as a service provider for com.hazelcast.instance.impl.NodeExtension. According to the ServiceLoader documentation The only requirement enforced by this facility is that provider classes must have a zero-argument constructor so that they can be instantiated during loading. To avoid the error you can disable the ServiceLoaderFeature with -H:-UseServiceLoaderFeature. That's where this is triggered from. You can also use -H:+TraceServiceLoaderFeature to see all the classes processed by this feature.

All 5 comments

Hi. Any updates on this issue? Maybe a temporary workaround? Thanks

I am also having this issue.

Just tried with the latest graalvm release (19.3.0), no changes:

Build on Server(pid: 27, port: 46577)*
[hazelcast-all-3.12.3:27]    classlist:   8,840.12 ms
[hazelcast-all-3.12.3:27]        (cap):   1,415.38 ms
[hazelcast-all-3.12.3:27]        setup:   3,640.53 ms
[hazelcast-all-3.12.3:27]     analysis:  50,884.02 ms
Fatal error: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Class com.hazelcast.instance.DefaultNodeExtension cannot be instantiated reflectively . It does not have a nullary constructor.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
        at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1005)
        at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:462)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:315)
        at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:454)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.executeCompilation(NativeImageBuildServer.java:402)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$processCommand$8(NativeImageBuildServer.java:339)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.withJVMContext(NativeImageBuildServer.java:420)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.processCommand(NativeImageBuildServer.java:336)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.processRequest(NativeImageBuildServer.java:280)
        at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$serve$7(NativeImageBuildServer.java:240)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Class com.hazelcast.instance.DefaultNodeExtension cannot be instantiated reflectively . It does not have a nullary constructor.
        at org.graalvm.nativeimage.hosted.RuntimeReflection.registerForReflectiveInstantiation(RuntimeReflection.java:127)
        at com.oracle.svm.hosted.ServiceLoaderFeature.handleType(ServiceLoaderFeature.java:222)
        at com.oracle.svm.hosted.ServiceLoaderFeature.duringAnalysis(ServiceLoaderFeature.java:112)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$8(NativeImageGenerator.java:710)
        at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:63)
        at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:710)
        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)
Error: Image build request failed with exit status 1
The command '/bin/sh -c native-image -jar hazelcast-all-${hazelcast_version}.jar --no-fallback --report-unsupported-elements-at-runtime --allow-incomplete-classpath --enable-all-security-services' returned a non-zero code: 1

The underlying problem is that com.hazelcast.instance.DefaultNodeExtension should provide a nullary constructor because it is registered as a service provider for com.hazelcast.instance.impl.NodeExtension. According to the ServiceLoader documentation The only requirement enforced by this facility is that provider classes must have a zero-argument constructor so that they can be instantiated during loading. To avoid the error you can disable the ServiceLoaderFeature with -H:-UseServiceLoaderFeature. That's where this is triggered from. You can also use -H:+TraceServiceLoaderFeature to see all the classes processed by this feature.

@CAFxX, please use this Dockerfile. It should run without errors:

FROM oracle/graalvm-ce:latest AS builder

ARG hazelcast_version=3.12.1

RUN gu install native-image
RUN yum -y install wget

WORKDIR /cp

RUN wget -q -c https://repo1.maven.org/maven2/com/hazelcast/hazelcast-all/${hazelcast_version}/hazelcast-all-${hazelcast_version}.jar

RUN native-image -H:-UseServiceLoaderFeature -jar hazelcast-all-${hazelcast_version}.jar --no-fallback --allow-incomplete-classpath

RUN mv hazelcast-all-${hazelcast_version} hazelcast

Was this page helpful?
0 / 5 - 0 ratings