2

I'm creating a Springboot microservice that is attempting to query a table stored in DynamoDB, I can get the table and its contents just fine using the AWS CLI, however when I try to do it through my micro service using IntelliJ, I receive this error that has almost no trace on the internet.

[Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause

java.lang.IllegalArgumentException: No duplicate ExecutionAttribute names allowed but both ExecutionAttributes 528c2979 and 6970b040 have the same name: DualstackEndpointsEnabled. ExecutionAttributes should be referenced from a shared static constant to protect against erroneous or unexpected collisions.

I have tried so many things with no avail, first moving from IntelliJ to launching the app through the command line using Maven manually to VSCode, I uninstalled the IntelliJ DynamoDB plugin thinking it might be interfering with this, killed AWS processes running on port 443 which is what AWS usually runs on, keep in mind the issue occurred before I even had the AWS CLI on my machine so I don't think having that installed would interfere with my workflow, and it would be a very odd decision if it did.

the code is very basic, just making a call using a channel name stored in the database, here is a snippet of the base method being called if it helps identify the issue

    public PageIterable<DynamoOrder> getOrdersByChannel(String channelName) {

    DynamoDbTable<DynamoOrder> orderTable = getTable();

    AttributeValue channelNameAttribute = AttributeValue.builder().s(channelName).build();
    Expression expression = Expression.builder().expression("marketplaceChannelName = :v_marketplaceChannelName")
            .putExpressionValue(":v_marketplaceChannelName", channelNameAttribute).build();

    return orderTable.scan(ScanEnhancedRequest.builder().filterExpression(expression).build());

}

any help would be much appreciated, thanks!

EDIT: thought I'd provide more information, here's the exact Exception thrown in the AWS SDK, I don't have the expertise nor the required knowledge to trace this back properly but maybe someone would, https://github.com/aws/aws-sdk-java-v2/blob/master/core/sdk-core/src/main/java/software/amazon/awssdk/core/interceptor/ExecutionAttribute.java

Humid-IDE
  • 21
  • 4

1 Answers1

0

To build a Spring based app using the AWS SDK for Java v2, use the Enhanced Client. The Amazon DynamoDB enhanced client is a high-level library that is part of the AWS SDK for Java version (v2).

It offers a straightforward way to map client-side classes to DynamoDB tables. You define the relationships between tables and their corresponding model classes in your code. Then you can intuitively perform various create, read, update, or delete (CRUD) operations on tables or items in DynamoDB.

For more information about the Enhanced Client, see this topic in the AWS Java DEV Guide:

Using the DynamoDB Enhanced Client in the AWS SDK for Java 2.x

If you look at the AWS Code Catelog, you will find this use case that shows how to use the DynamoDB Java API to create a Spring BOOT DEMO app that performs CRUD operations on a DynamoDB table.

https://docs.aws.amazon.com/code-library/latest/ug/dynamodb_example_cross_DynamoDBDataTracker_section.html

This example shows how to successfully use the IntelliJ IDE to build your AWS Java project. (For devs reading this thread, this use case is also provided in different programming languages such as .NET or Python).

smac2020
  • 9,637
  • 4
  • 24
  • 38
  • I just browsed the example repo and a lot of the code on there is replicated very similarly on the codebase I am currently working on, I cannot completely restart the config from scratch because I am not the only person working on this. We are indeed using the enhanced dynamodb client. The issue is occurring despite all of that, it is quite cryptic and just a nudge in the right direction would help me out a lot. – Humid-IDE Aug 11 '22 at 22:12
  • I have never seen the error you are describing. Check the POM dependencies on your end. I am curious what’s happening on your end. – smac2020 Aug 11 '22 at 22:38
  • my pom file is a bit bloated in all honesty, the project is running springboot, confluent Kafka, with an Avro schema for serialization/deserialization, and connections to AWS and an external API that I'm not going to mention. the micro service builds and runs completely fine, this DynamoDB issue is part of a ticket I'm working on and it's baffled everyone I've asked, I'm happy to provide any information from pom or otherwise. I made an edit to the original post with a link to the exception being thrown in the AWS codebase if that helps. – Humid-IDE Aug 11 '22 at 22:42