Aws-sdk-java: Problem when sending message in SQS: NoSuchFieldError: SERVICE_ID

Created on 5 Sep 2018  路  2Comments  路  Source: aws/aws-sdk-java

Hi,

I have configured SQS client in java to push message into SQS Queue.
I have followed this approach https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/standard-queues-getting-started-java.html
But I am getting below mentioned error when I run the jar using AWS lambda.

Caused by: java.lang.NoSuchFieldError: SERVICE_ID
at com.amazonaws.services.sqs.AmazonSQSClient.executeSendMessage(AmazonSQSClient.java:1683)
at com.amazonaws.services.sqs.AmazonSQSClient.sendMessage(AmazonSQSClient.java:1664)

Bellow is the snippet of pom.xml

 <dependency>
  <groupId>com.amazonaws.serverless</groupId>
  <artifactId>aws-serverless-java-container-spring</artifactId>
  <version>1.1</version>
</dependency>

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-lambda-java-log4j2</artifactId>
  <version>1.0.0</version>
</dependency>

<dependency>
  <artifactId>aws-java-sdk-kms</artifactId>
  <groupId>com.amazonaws</groupId>
  <version>1.11.327</version>
</dependency>

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk-route53</artifactId>
  <version>1.11.327</version>
</dependency>
<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk-sqs</artifactId>
  <version>1.11.401</version>

</dependency>
response-requested

Most helpful comment

Can you provide the version of the SDK?

This error usually indicates a version mismatch between core and client. The version of core must be the same or newer than the client version.

Also, check the BOM for an easier way to manage SDK dependencies.
https://aws.amazon.com/blogs/developer/managing-dependencies-with-aws-sdk-for-java-bill-of-materials-module-bom/

All 2 comments

Can you provide the version of the SDK?

This error usually indicates a version mismatch between core and client. The version of core must be the same or newer than the client version.

Also, check the BOM for an easier way to manage SDK dependencies.
https://aws.amazon.com/blogs/developer/managing-dependencies-with-aws-sdk-for-java-bill-of-materials-module-bom/

Adding BOM dependency solved the problem. @debora-ito You were right, I was using different versions for sdk-kms,sdk-route53 and sdk-sqs. Thank you!! I have added below mentioned dependency management section and now all the sdk versions are the same.

<dependencyManagement>
<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-bom</artifactId>
    <version>1.11.354</version>
    <type>pom</type>
    <scope>import</scope>
  </dependency>
</dependencies>
</dependencyManagement>
Was this page helpful?
0 / 5 - 0 ratings