Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SES Service For sending mail using java

I am facing below error while using AWS SES Mail sending example?

"Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.client.AwsSyncClientParams.getAdvancedConfig()Lcom/amazonaws/client/builder/AdvancedConfig;
    at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.<init>(AmazonSimpleEmailServiceClient.java:277)
    at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.<init>(AmazonSimpleEmailServiceClient.java:261)
    at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder.build(AmazonSimpleEmailServiceClientBuilder.java:61)
    at com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder.build(AmazonSimpleEmailServiceClientBuilder.java:27)
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
    at saurabh.aws.learning.awsLearning.SendMailService.main(SendMailService.java:50)
"
like image 996
Saurabh Gupta Avatar asked Oct 18 '25 09:10

Saurabh Gupta


2 Answers

Problem:

I also faced same issue. The reason was that I was using difference artefact versions for my aws libraries: aws-java-sdk-core and aws-java-sdk-s3.

Solution (Maven):

In case you are using Maven, Amazon suggests to use BOM dependencyManagement. This way you ensure that the modules you specify use the same version of the SDK and that they're compatible with each other.

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

And as you already declared the SDK version in the BOM, you don't need to specify the version number for each component. Like this:

<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-s3</artifactId>
  </dependency>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-sqs</artifactId>
  </dependency>
</dependencies>

Source: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-project-maven.html#configuring-maven-individual-components

like image 81
Fabio Farath Avatar answered Oct 20 '25 00:10

Fabio Farath


I have experienced this error myself. It is caused most likely by different versions of artifacts like: aws-java-sdk-ses and aws-java-sdk-core. Try using the same version for the two above in your pom.xml (if you are using maven). If this doesnt work, can you share your pom.xml ?

like image 22
lost in binary Avatar answered Oct 20 '25 00:10

lost in binary