question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native image build fails due to CachedSupplier/SplittableRandom

See original GitHub issue

Describe the bug

Building a native image with Graal fails with the latest AWS SDK 2.17.238 The issue did not yet exist with AWS SDK 2.16.51.

I was able to work around it by using --initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier.

Expected Behavior

No error

Current Behavior

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=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace: 
        at parsing software.amazon.awssdk.utils.cache.CachedSupplier.jitterTime(CachedSupplier.java:326)

Reproduction Steps

Can be reproduced with Graal 21.3.0 and ‘GraalVM 22.1.0.0-Final Java 17 Mandrel Distribution’.

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.17.238

JDK version used

11 and 17

Operating System and version

Linux

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Chexpircommented, Aug 3, 2022

Thanks! Yes, I also have the same problem, my relateddependencies are:

    implementation("software.amazon.awssdk:url-connection-client:${awsPluginVersion}") {
        exclude(group: "software.amazon.awssdk", module: "netty-nio-client")
        exclude(group: "software.amazon.awssdk", module: "apache-client")
    }
    implementation("software.amazon.awssdk:apache-client:${awsPluginVersion}") {
        exclude(group: "commons-logging", module: "commons-logging")
    }
...
    testImplementation "software.amazon.awssdk:netty-nio-client:${awsPluginVersion}"
1reaction
MarkusKramercommented, Jul 26, 2022

Hi. Okay interesting. Maybe an important aspect is that I’m using the url-connection-client (because I’m using the AWS SDK with Quarkus). I’m including the SDK like this in my Gradle build.gradle.kt file:

    implementation(enforcedPlatform("software.amazon.awssdk:bom:2.17.238"))
    implementation("software.amazon.awssdk:url-connection-client")
    fun awsImplementation(artifactId: String) {
        implementation("software.amazon.awssdk:$artifactId") {
            exclude("software.amazon.awssdk", "netty-nio-client")
            exclude("software.amazon.awssdk", "apache-client")
        }
    }
    awsImplementation("s3")
    awsImplementation("sts")

Hope that helps to reproduce. At least one other person also got the same issue as reported here https://github.com/quarkusio/quarkus/issues/14904#issuecomment-1057799863

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Random/SplittableRandom instances in ...
Embedding them in a native image results in the seed value that was generated at build-time to be cached in the native image,...
Read more >
Quarkus Native Image Build Failure - java - Stack Overflow
This means that if you use Random/SplittableRandom in your code this will be initialized at build time and thus this error.
Read more >
Tips for writing native applications - Quarkus
Instances created during image generation have cached seed values and don't behave as expected. Which is more often than not caused by Quarkus...
Read more >
Fix GraalVM Native Image Build Issues - Simply-How.com
1. Introduction 2. Getting started 3. Build-time errors
Read more >
New Feature - Release Notes - Java Bug System
createDirectories to get MaxPathLength.java failure details ... [JDK-7089914] - Focus on image icons are not visible in javaws cache with high contrast mode ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found