Skip to content

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

Closed
@klopfdreh

Description

@klopfdreh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.graalvmp2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions