AWS SES Service For sending mail using java

浪子不回头ぞ 提交于 2019-12-22 12:19:52

问题


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)
"

回答1:


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




回答2:


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 ?




回答3:


Even i had the same issue :

Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.client.AwsSyncClientParams.getAdvancedConfig()Lcom/amazonaws/client/builder/AdvancedConfig;

I tried configuring auto-scaling for my DynamoDB from java i faced this issue.

Solution:

We need to make sure aws sdk version match with the specific service version. I used below dependency when i got exception,

compile group: 'com.amazonaws', name: 'aws-java-sdk-applicationautoscaling', version: '1.11.500'
compile group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.11.123'

After changing to same version, issue got solved

compile group: 'com.amazonaws', name: 'aws-java-sdk-applicationautoscaling', version: '1.11.500'
compile group: 'com.amazonaws', name: 'aws-java-sdk-core', version: '1.11.500'


来源:https://stackoverflow.com/questions/53570061/aws-ses-service-for-sending-mail-using-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!