Fix GraalVM configuration of `software.amazon.awssdk:apache-client`
The GraalVM configuration of software.amazon.awssdk:apache-client is incomplete. Without this change, software.amazon.awssdk.http.apache.ApacheHttpClient fails with:
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
at java.lang.Class.ensureInitialized(DynamicHub.java:525)
at software.amazon.awssdk.http.apache.ApacheHttpClient$ApacheConnectionManagerFactory.getPreferredSocketFactory(ApacheHttpClient.java:658)
at software.amazon.awssdk.http.apache.ApacheHttpClient$ApacheConnectionManagerFactory.create(ApacheHttpClient.java:637)
at software.amazon.awssdk.http.apache.ApacheHttpClient.createClient(ApacheHttpClient.java:151)
at software.amazon.awssdk.http.apache.ApacheHttpClient.<init>(ApacheHttpClient.java:125)
at software.amazon.awssdk.http.apache.ApacheHttpClient.<init>(ApacheHttpClient.java:104)
at software.amazon.awssdk.http.apache.ApacheHttpClient$DefaultBuilder.buildWithDefaults(ApacheHttpClient.java:629)
at software.amazon.awssdk.http.SdkHttpClient$Builder.build(SdkHttpClient.java:69)
at io.micronaut.aws.sdk.v2.client.apache.ApacheClientFactory.doCreateClient(ApacheClientFactory.java:62)
at io.micronaut.aws.sdk.v2.client.apache.ApacheClientFactory.apacheClient(ApacheClientFactory.java:47)
at io.micronaut.aws.sdk.v2.client.apache.$ApacheClientFactory$ApacheClient0$Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354)
... 81 common frames omitted
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl (Caused by java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1158)
at org.apache.commons.logging.LogFactory$2.run(LogFactory.java:960)
at java.security.AccessController.executePrivileged(AccessController.java:169)
at java.security.AccessController.doPrivileged(AccessController.java:83)
at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:957)
at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:624)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.apache.http.conn.ssl.AbstractVerifier.<init>(AbstractVerifier.java:61)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<init>(AllowAllHostnameVerifier.java:44)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<clinit>(AllowAllHostnameVerifier.java:46)
... 94 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.LogFactoryImpl
at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:52)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.lang.ClassLoader.loadClass(ClassLoader.java:133)
at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1020)
Motivation and Context
Modifications
Testing
Screenshots (if appropriate)
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
Checklist
- [x] I have read the CONTRIBUTING document
- [x] Local run of
mvn installsucceeds - [x] My code follows the code style of this project
- [ ] My change requires a change to the Javadoc documentation
- [ ] I have updated the Javadoc documentation accordingly
- [ ] I have added tests to cover my changes
- [x] All new and existing tests passed
- [ ] I have added a changelog entry. Adding a new entry must be accomplished by running the
scripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes. - [ ] My change is to implement 1.11 parity feature and I have updated LaunchChangelog
License
- [x] I confirm that this pull request can be released under the Apache 2 license
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication
Looks like our native image tests failed after this change
Could not resolve org.apache.commons.logging.impl.Jdk14Logger for reflection configuration. Reason: java.lang.ClassNotFoundException: org.apache.commons.logging.impl.Jdk14Logger. To allow unresolvable reflection configuration, use option -H:+AllowIncompleteClasspath
--
3623 | Verify that the configuration matches the schema described in the -H:PrintFlags=+ output for option ReflectionConfigurationResources.
3624 | Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
3625 | Error: Image build request failed with exit status 1
3626 | com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
3627 | at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1676)
3628 | at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1426)
3629 | at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1387)
3630 | at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1374)
Where is that aws-sdk-java-v2-native-image-test application? Or how can I reproduce the failure?
You can use the commands here to reproduce the issue https://github.com/aws/aws-sdk-java-v2/blob/master/buildspecs/archetype-native-image-test.yml#L7-L26 Note that you need to clone aws-sdk-java-v2 repo first.
It worked for me:
2022-09-21 13:32:30:938 +0200 [main] INFO com.test.App - Application starts
2022-09-21 13:32:31:448 +0200 [main] INFO com.test.App - Application ends
Using GraalVM CE 22.2.0 (JDK 11)
Thanks for verifying. We use JDK 8 to run the tests; not sure if it only fails on JDK 8. We will take a look
Java 8 support was removed in GraalVM CE 21.3.0, 1 year ago. Since then, there have been 3 releases (22.0 in January, 22.1 in April and 22.2 in July). 22.3 is coming out next month.
Note that I generated the config changes in this PR by using a 22.2 agent. If you have a 21.2 version locally, please try the tests yourself.
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
0 Code Smells
No Coverage information
0.0% Duplication