Skip to content

Fix GraalVM configuration of software.amazon.awssdk:apache-client #3428

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

Merged
merged 2 commits into from
Jan 4, 2023

Conversation

alvarosanchez
Copy link
Contributor

@alvarosanchez alvarosanchez commented Sep 16, 2022

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • 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
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

Sorry, something went wrong.

The GraalVM configuration of `software.amazon.awssdk:apache-client` is incomplete. Without this change, `software.amazon.awssdk.http.apache.pacheHttpClient` 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)
```
@alvarosanchez alvarosanchez requested a review from a team as a code owner September 16, 2022 11:35
alvarosanchez added a commit to micronaut-projects/micronaut-aws that referenced this pull request Sep 16, 2022
zoewangg
zoewangg previously approved these changes Sep 16, 2022
Copy link
Contributor

@zoewangg zoewangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution!

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@zoewangg
Copy link
Contributor

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)

@zoewangg zoewangg dismissed their stale review September 17, 2022 00:36

Dismiss review because tests failed

@alvarosanchez
Copy link
Contributor Author

Where is that aws-sdk-java-v2-native-image-test application? Or how can I reproduce the failure?

@zoewangg
Copy link
Contributor

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.

@alvarosanchez
Copy link
Contributor Author

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)

@zoewangg
Copy link
Contributor

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

@alvarosanchez
Copy link
Contributor Author

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.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@zoewangg zoewangg enabled auto-merge (squash) January 4, 2023 01:09
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@zoewangg zoewangg merged commit ecc12b4 into aws:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants