Skip to content

AWS JAVA dynamoDB enhanced client putItem class cast exception

When I used enhanced client to put but it throws class cast exception.

DynamoDbTable<Tableclass> recordTable = enhanceClient.table(tableName, Tableclass.class);

Tableclass tableclass = new Tableclass();

It gives me error java.lang.ClassCastException: com.db.dynamo.Tableclass cannot be cast to com.db.dynamo.Tableclass


This worked for me SpringBoot – Java AWS SDK 2 DynamoDB Enhanced Client and devtools problem

So basically the issue was with spring dev tools and its class loader(2 in number), so you can either remove it or move dynamo to the same class loader.