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

Native image build fails due to CachedSupplier/SplittableRandom #3323

Closed
MarkusKramer opened this issue Jul 25, 2022 · 8 comments · Fixed by #3768
Closed

Native image build fails due to CachedSupplier/SplittableRandom #3323

MarkusKramer opened this issue Jul 25, 2022 · 8 comments · Fixed by #3768
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@MarkusKramer
Copy link

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

@yasminetalby
Copy link

Hello @MarkusKramer ,

I wasn't able to reproduce this issue. Building a native image does work with the Java AWS SDK 2.17.238 and GraalVM 22.1.0 Java 17 CE on my end.

Could you elaborate the reproduction steps?

You can also find guided documentation for GraalVM Native Image support for Java AWS SDK v2 here: https://aws.amazon.com/blogs/developer/graalvm-native-image-support-in-the-aws-sdk-for-java-2-x/

Best,

Yasmine

@MarkusKramer
Copy link
Author

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 quarkusio/quarkus#14904 (comment)

@yasminetalby
Copy link

Hello @MarkusKramer,

Thank you very much for your response and for sharing your build.gradle.kt file.
We have added this bug fix to our backlog.

Best,

Yasmine

@yasminetalby yasminetalby removed the needs-triage This issue or PR still needs to be triaged. label Jul 26, 2022
@Chexpir
Copy link

Chexpir commented 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}"

@L-Applin
Copy link
Contributor

L-Applin commented Oct 7, 2022

Hello @MarkusKramer !
We think we might have a fix for this issue that would make it so -initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier is not required, but I cannot seem to reproduce the problem described in this issue. Therefore I cannot really test our solution.

I have put together a small demo project to try to reproduce it, using the same Gradle dependencies. I have tried to compile and run this small project with GraalVM 22.1.0 and 22.2 both with java 11 and 17. All worked fine on my end.

Again, thanks for submitting this issue to our attention!

@yaseenbit
Copy link

I am also getting this issue

@zeppelinux
Copy link

Having this issue as well.

To reproduce:

  1. Checkout the quarked-ddns project
  2. Remove --initialize-at-runtime value in this file https://github.com/zeppelinux/quarked-ddns/blob/main/src/main/resources/application.properties
  3. See native build fails with the reported exception.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants