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

ClassNotFoundException after Spring Boot Native Image compilation for s3/internal/ApplyUserAgentInterceptor.java #5127

Closed
klopfdreh opened this issue Apr 20, 2024 · 4 comments · Fixed by #5184
Labels
bug This issue is a bug. graalvm p2 This is a standard priority issue

Comments

@klopfdreh
Copy link
Contributor

klopfdreh commented Apr 20, 2024

Describe the bug

The reflect-config.json is missing in the s3 for services-custom/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/ApplyUserAgentInterceptor.java which causes the Spring Boot Native build to throw a java.lang.ClassNotFoundException

Expected Behavior

When the reflect-config.json is added like in other packages and it is added via -H:ReflectionConfigurationResources to the native build, no java.lang.ClassNotFoundException is going to occur anymore.

Current Behavior

There is a java.lang.ClassNotFoundException during the runtime as the class ApplyUserAgentInterceptor.java can not be loaded JIT in a native image.

java.lang.ClassNotFoundException: software.amazon.awssdk.transfer.s3.internal.ApplyUserAgentInterceptor
at c.o.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:123)
at c.o.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:87)
at java.lang.Class.forName(DynamicHub.java:1324)
at java.lang.Class.forName(DynamicHub.java:1287)
at java.lang.Class.forName(DynamicHub.java:1280)
at s.a.a.c.internal.util.ClassLoaderHelper.loadClass(ClassLoaderHelper.java:114)
at s.a.a.c.internal.util.ClassLoaderHelper.loadClass(ClassLoaderHelper.java:73)
at s.a.a.c.i.ClasspathInterceptorChainFactory.createExecutionInterceptor(ClasspathInterceptorChainFactory.java:123)
... 206 common frames omitted

Reproduction Steps

Native compile a Spring Boot application like described here: https://aws.amazon.com/de/blogs/developer/graalvm-native-image-support-in-the-aws-sdk-for-java-2-x/ - note: the -H:ReflectionConfigurationResources=META-INF/native-image/software.amazon.awssdk/s3/reflect-config.json is not working anymore as it is missing.

Possible Solution

Add the reflect-config.json to the s3 package with the following content.

[
  {
    "name": "software.amazon.awssdk.transfer.s3.internal.ApplyUserAgentInterceptor",
    "methods": [
      {
        "name": "<init>",
        "parameterTypes": []
      }
    ]
  }
]

Additional Information/Context

N/A

AWS Java SDK version used

2.25.34

JDK version used

jdk17.0.10

Operating System and version

linux / ubi9-minimal:9.3-1612

@klopfdreh klopfdreh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 20, 2024
@klopfdreh
Copy link
Contributor Author

klopfdreh commented Apr 23, 2024

Same goes for software.amazon.awssdk.crt.s3.S3Client but I guess it is in a different package, so a separate reflect-config.json is required.

Edit: I created an issue in AWS CRT for this.

@debora-ito
Copy link
Member

@klopfdreh acknowledged, marking as a bug.

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

klopfdreh commented Apr 26, 2024

Hey @debora-ito maybe it would be a good idea to introduce the native support to the code as in Spring Cloud AWS - see: https://github.com/awspring/spring-cloud-aws/pull/856/files - this way there would be no issues even if you move the classes.

Edit: Saw that those classes are Spring related and can't be used in the SDK. Sorry for the noise.

Copy link

github-actions bot commented May 6, 2024

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