-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
InternalConfig throws exception in runtime with native application #3035
Comments
For any future readers, This issue isn't directly related to AWS SDK rather related to GrallVM. I could run my application with below configs. Hints are required for GrallVM to know your classes. class ApplicationRuntimeHints : RuntimeHintsRegistrar {
override fun registerHints(hints: RuntimeHints, classLoader: ClassLoader?) {
hints.resources().registerResource(ClassPathResource("com/amazonaws/internal/config/awssdk_config_default.json"))
hints.resources().registerResource(ClassPathResource("com/amazonaws/partitions/endpoints.json"))
hints.resources().registerResource(ClassPathResource("com/amazonaws/sdk/versionInfo.properties"))
HashSet::class.java.declaredConstructors.forEach { hints.reflection().registerConstructor(it, ExecutableMode.INVOKE) }
AWSS3V4Signer::class.java.declaredConstructors.forEach { hints.reflection().registerConstructor(it, ExecutableMode.INVOKE) }
}
} RegisterReflectionForBinding annotation is required for serilization and deserialization of classes. @SpringBootApplication
@ConfigurationPropertiesScan
@ImportRuntimeHints(ApplicationRuntimeHints::class)
@RegisterReflectionForBinding(
InternalConfigJsonHelper::class,
JsonIndex::class,
HttpClientConfigJsonHelper::class,
HostRegexToRegionMappingJsonHelper::class,
Partitions::class,
Partition::class,
)
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
} And lastly, we need to add dynamic proxy config file to resources (or any path you want) and update pom.xml GrallVM plugin (or gradle if you use). [
[
"org.apache.http.conn.HttpClientConnectionManager",
"org.apache.http.pool.ConnPoolControl",
"com.amazonaws.http.conn.Wrapped"
]
] <plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs>
<arg>--initialize-at-build-time=org.apache.commons.logging.LogFactory</arg>
<arg>-H:DynamicProxyConfigurationFiles=src/main/resources/proxies.json</arg>
</buildArgs>
</configuration>
</plugin> |
COMMENT VISIBILITY WARNINGComments on closed issues are hard for our team to see. |
Describe the bug
Hello,
I use Spring Native for my application. I use AWS S3 Sdk for my S3 related operations.
I can build and run my application with normal maven build.
When it comes to native application, i can build my application successfully but when i run my application aws-java-sdk-core throws exception because it cannot load
awssdk_config_default.json
file.I don't know why this is happening with native application.
Thank you 🧡
Expected Behavior
I expect to not throwing any exception when i run my application with native build.
Just like old fashion java jar application.
Current Behavior
Currently, InternalConfig throws exception during run time.
You can see stack trace of exception that throw during runtime (last part is the most important);
Reproduction Steps
I created a sample repo to reproduce the issue.
You can see from below link;
https://github.com/fethiyildiz/awsnativedemo
I use below command to create native application;
./mvnw native:compile -Pnative -DskipTests
And to run the application;
./target/awsnativedemo
But in a shortest version, below snippet is the cause of issue.
Possible Solution
No response
Additional Information/Context
I don't know am i missing something but just in case i also added 2 Dockerfile to make easy to test for you
One with old fashion jar application and the other one is native.
You can see from repo.
Dockerfile => native
Dockerfile_basic => jar
Also i put placeholders for access and secret keys. You can see from application.yaml file.
AWS Java SDK version used
1.12.566
JDK version used
java version "20.0.2" 2023-07-18 Java(TM) SE Runtime Environment Oracle GraalVM 20.0.2+9.1 (build 20.0.2+9-jvmci-23.0-b14) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 20.0.2+9.1 (build 20.0.2+9-jvmci-23.0-b14, mixed mode, sharing)
Operating System and version
macOS Ventura 13.3.1
The text was updated successfully, but these errors were encountered: