apache / apache/camel-quarkus

Camel Quarkus + Azure Cosmos DB in Native Mode Issue Detected an instance of Random/SplittableRandom class

Open
#3,891 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
302
Forks
232
Avg merge
1d 20h
Merged PRs (30d)
114

Description

Hi Guys, I'm working in a project that needs use Azure DB Cosmos using Quarkus with GraalVM, bellow my stack

OS - MacOS Monterrey over M1 Max Machine arc64 (the same problem happens using Linux Containers)

To reproduce the issue

Maven Dependencies
```

11
11
3.8.1
true
UTF-8
UTF-8
quarkus-bom
io.quarkus.platform
2.10.1.Final
3.0.0-M7



${quarkus.platform.group-id}
${quarkus.platform.artifact-id}
${quarkus.platform.version}
pom
import


com.azure
azure-sdk-bom
1.2.2
pom
import






io.netty
netty-transport-native-epoll





io.quarkus
quarkus-funqy-knative-events


org.apache.camel.quarkus
camel-quarkus-azure-cosmosdb
2.9.0



org.projectlombok
lombok
1.18.24



io.quarkus
quarkus-junit5
test


io.rest-assured
rest-assured
test


io.quarkus
quarkus-arc


```

Command to try to generate the native bin

# Only Mac OS Binary
```
mvn clean -DskipTests package -Pnative -Dquarkus.native.native-image-xmx=4g
```

# Only Linux arch64 Binary

```
./mvnw -DskipTests clean compile package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true -Dquarkus.native.builder-image=graalbasev17 -Dquarkus.native.native-image-xmx=5g
```

The Error Output

```
[1/7] Initializing... (7.9s @ 0.27GB)
Version info: 'GraalVM 22.1.0 Java 17 CE'
C compiler: gcc (redhat, aarch64, 8.5.0)
Garbage collector: Serial GC
3 user-provided feature(s)
- io.quarkus.runner.AutoFeature
- io.quarkus.runtime.graal.DisableLoggingAutoFeature
- io.quarkus.runtime.graal.ResourcesFeature
13:29:41,920 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting PartitionKeyAccessor...
13:29:42,059 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosClientBuilderAccessor...
13:29:42,064 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting DirectConnectionConfigAccessor...
13:29:42,182 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBatchAccessor...
13:29:42,183 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBatchOperationResultAccessor...
13:29:42,183 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBatchRequestOptionsAccessor...
13:29:42,184 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBatchResponseAccessor...
13:29:42,185 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBulkExecutionOptionsAccessor...
13:29:42,185 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBulkExecutionThresholdsStateAccessor...
13:29:42,186 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosBulkItemResponseAccessor...
13:29:42,186 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosChangeFeedRequestOptionsAccessor...
13:29:42,187 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosContainerPropertiesAccessor...
13:29:42,187 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosItemRequestOptionsAccessor...
13:29:42,188 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosItemResponseBuilderAccessor...
13:29:42,188 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosPatchOperationsAccessor...
13:29:42,189 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosQueryRequestOptionsAccessor...
13:29:42,189 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting FeedResponseAccessor...
13:29:42,233 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosClientAccessor...
13:29:42,234 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosAsyncClientEncryptionKeyAccessor...
13:29:42,236 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosAsyncContainerAccessor...
13:29:42,236 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosAsyncDatabaseAccessor...
13:29:42,250 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosPageFluxAccessor...
13:29:42,265 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosDiagnosticsAccessor...
13:29:42,266 INFO [com.azu.cos.imp.ImplementationBridgeHelpers] Setting CosmosExceptionAccessor...
13:29:44,573 INFO [com.azu.cos.imp.dir.RntbdTransportClient] Using default Direct TCP options: azure.cosmos.directTcp.defaultOptions
[2/7] Performing analysis... [] (8.3s @ 0.94GB)
8,997 (92.61%) of 9,715 classes reachable
11,940 (59.46%) of 20,081 fields reachable
36,329 (78.61%) of 46,214 methods reachable
572 classes, 0 fields, and 0 methods registered for reflection
Fatal error: org.graalvm.compiler.debug.GraalError: 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.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:269)
at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$9(ImageHeapScanner.java:611)
at com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
------------------------------------------------------------------------------------------------------------------------
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
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.
```

Addional load class initialization info over properties file

```
quarkus.native.additional-build-args=--allow-incomplete-classpath,--initialize-at-run-time=org.acme.RandomWrapper\\,\
io.netty.channel.epoll.Epoll\\,\
io.netty.channel.epoll.EpollEventLoop\\,\
io.netty.channel.epoll.Native\\,\
io.netty.channel.epoll.EpollEventArray\\,\
io.netty.channel.DefaultFileRegion\\,\
io.netty.channel.unix.Errors\\,\
org.apache.http.impl.auth.NTLMEngineImpl\\,\
io.grpc.netty.shaded.io.netty.util.internal.logging.Log4JLogger\\,\
io.netty.util.internal.logging.Log4JLogger
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Maven dependency block, the native-build commands, and the reported GraalVM error. Use the mentioned --trace-object-instantiation=java.util.Random diagnostic to identify the instantiation path. Done means the reproduced native build completes without the Random/SplittableRandom image-heap failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, java
Domain
backend, build-system, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.