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

Got java.lang.NoClassDefFoundError: KmsClient when set up S3EncryptionClient #397

Open
hieuwu opened this issue Oct 31, 2024 · 0 comments
Open
Labels
pending_release Fix/Feature is merged, but not pushed to Maven

Comments

@hieuwu
Copy link
Contributor

hieuwu commented Oct 31, 2024

Security issue notifications

N/A

Problem:

Got exception when run test and run application when provide S3EncryptionClient with kms

Caused by: java.lang.NoClassDefFoundError: software/amazon/awssdk/services/kms/KmsClient
	at software.amazon.encryption.s3.S3EncryptionClient$Builder.build(S3EncryptionClient.java:1142)

The root cause of the problem is that kmsClient class comes from different dependencies, while other type of security key is in the same package of the SDK.

How to reproduce:

  1. Add the dependency
    implementation("software.amazon.encryption.s3:amazon-s3-encryption-client-java:3.3.0")
  2. Create a configuration class
@Configuration
class S3Configuration {
    @Bean
    fun s3Client(): S3Client {
        return S3EncryptionClient.builder()
            .kmsKeyId("sdfdsfds")
            .region(Region.AP_SOUTHEAST_2).build()
    }
}
  1. Start the application or test with ./gradlew startBootRun or ./gradlew runTest
    The exception is throw when the application actually runs.

Solution:

  • Check for existence of KmsClient class when kmsKeyId is set. This would help developer easier to troubleshoot the problem & take proper action
  • Update document to emphasize the dependency they need to add when use kmsKeyId

Out of scope:

Is there anything the solution will intentionally NOT address?

@hieuwu hieuwu changed the title Got java.lang.NoClassDefFoundError: KmsClient at Run Time when set up S3EncryptionClient Got java.lang.NoClassDefFoundError: KmsClient when set up S3EncryptionClient Oct 31, 2024
@texastony texastony added the pending_release Fix/Feature is merged, but not pushed to Maven label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending_release Fix/Feature is merged, but not pushed to Maven
Projects
None yet
Development

No branches or pull requests

2 participants