AWS java.lang.NoSuchFieldError: ENDPOINT_OVERRIDDEN

Last modified date

Comments: 0

Error

Recently whilst developing a Spring Boot app, I ran across the following error after adding a new AWS SDK SES maven dependency:

java.lang.NoSuchFieldError: ENDPOINT_OVERRIDDEN
	at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.executeSendEmail(AmazonSimpleEmailServiceClient.java:3845) ~[aws-java-sdk-ses-1.11.905.jar:na]
	at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.sendEmail(AmazonSimpleEmailServiceClient.java:3827) ~[aws-java-sdk-ses-1.11.905.jar:na]

The error is caused by AWS SDK dependency mismatch.

In the Spring Boot application, I had maven dependencies for EC2 and Secrets Manager as well as the SES dependency.

Each of these dependencies will pull in a different version of the aws-java-sdk-core dependency. This results in the error above because your project will now be running different versions of the AWS core module.

Solution

To solve this issue, you must add the following BOM (bill of materials) into your POM file.

The BOM takes care of managing the version of the dependencies that are imported.

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>com.amazonaws</groupId>
			<artifactId>aws-java-sdk-bom</artifactId>
			<version>1.11.907</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

Once added remove all the version numbers of the individual AWS maven dependencies, as the BOM module will take care of the versioning for us.

References

https://aws.amazon.com/blogs/developer/managing-dependencies-with-aws-sdk-for-java-bill-of-materials-module-bom/

JakTech

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.