Error about duplicate ExecutionAttributes when calling a query using the DynamoDB AWS SDK for Java

Viewed 76

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

1 Answers

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

Related