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

GraalVM native image fails because of software.amazon.awssdk.crt.s3.S3Client #5530

Closed
klopfdreh opened this issue Aug 23, 2024 · 2 comments · Fixed by #5531
Closed

GraalVM native image fails because of software.amazon.awssdk.crt.s3.S3Client #5530

klopfdreh opened this issue Aug 23, 2024 · 2 comments · Fixed by #5531
Labels
bug This issue is a bug. graalvm p2 This is a standard priority issue

Comments

@klopfdreh
Copy link
Contributor

Describe the bug

Because the software.amazon.awssdk.crt.s3.S3Client can't be resolved without the reflection hint the application fails with an exception.

Expected Behavior

The native image should run without any issues.

Current Behavior

Application fails with the following message

{"timestamp":"2024-08-13T12:12:48.031+0200","level":"ERROR","thread":"main","logger":"org.springframework.cloud.task.listener.TaskLifecycleListener","message":"An event to end a task has been received for a task that has not yet started.","context":"default"}
Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's3AsyncClient': Instantiation of supplied bean failed
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1180)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149)
at de.axa.lums.batch.basic.tasks.s3.uploader.S3UploaderApplication.main(S3UploaderApplication.java:28)
at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: java.lang.IllegalStateException: Could not load classes from AWS Common Runtime (CRT) library.software.amazon.awssdk.crt:crt is a required dependency; make sure you have it on the classpath.
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.validateCrtInClassPath(DefaultS3CrtAsyncClient.java:403)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.initializeS3CrtAsyncHttpClient(DefaultS3CrtAsyncClient.java:153)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.initializeS3AsyncClient(DefaultS3CrtAsyncClient.java:142)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.<init>(DefaultS3CrtAsyncClient.java:83)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.<init>(DefaultS3CrtAsyncClient.java:77)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient$DefaultS3CrtClientBuilder.build(DefaultS3CrtAsyncClient.java:313)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient$DefaultS3CrtClientBuilder.build(DefaultS3CrtAsyncClient.java:184)
at io.awspring.cloud.autoconfigure.s3.S3CrtAsyncClientAutoConfiguration.s3AsyncClient(S3CrtAsyncClientAutoConfiguration.java:82)
at io.awspring.cloud.autoconfigure.s3.S3CrtAsyncClientAutoConfiguration__BeanDefinitions.lambda$getSAsyncClientInstanceSupplier$1(S3CrtAsyncClientAutoConfiguration__BeanDefinitions.java:41)
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68)
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54)
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:206)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:219)
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:206)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:949)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1237)
... 16 more
Caused by: java.lang.ClassNotFoundException: software.amazon.awssdk.crt.s3.S3Client
at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:143)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:106)
at [email protected]/java.lang.Class.forName(DynamicHub.java:1387)
at [email protected]/java.lang.Class.forName(DynamicHub.java:1352)
at [email protected]/java.lang.Class.forName(DynamicHub.java:1346)
at software.amazon.awssdk.core.internal.util.ClassLoaderHelper.loadClass(ClassLoaderHelper.java:114)
at software.amazon.awssdk.services.s3.internal.crt.DefaultS3CrtAsyncClient.validateCrtInClassPath(DefaultS3CrtAsyncClient.java:401)
... 33 more

Reproduction Steps

Build an application with AWS SDK V2 and AWS CRT and use S3AsyncClient.crtBuilder() with S3TransferManager.builder().s3Client(s3AsyncClient).build()

Possible Solution

Add the following lines to reflect-config.json

  {
    "name": "software.amazon.awssdk.crt.s3.S3Client",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  },

Additional Information/Context

No response

AWS Java SDK version used

current

JDK version used

bellsoft-liberica-vm-openjdk22.0.1+10-24.0.1+1-linux-amd64

Operating System and version

Linux

@klopfdreh klopfdreh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 23, 2024
@debora-ito debora-ito added graalvm p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Aug 23, 2024
@debora-ito
Copy link
Member

Thank you for the PR!

Copy link

This issue is now closed. 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.

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. graalvm p2 This is a standard priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants