Reputation: 704
I am writing transactions into Kinesis Stream(using AWS SDK, JAVA), but the putRecord is failing with the reason of "Marshalling error". I tried to send a simple string(instead of my complex object), but still getting the same error. Below is the stacktrace snippet.
AWS SDK version: 1.11.76
com.amazonaws.SdkClientException: Unable to marshall request to JSON: com.fasterxml.jackson.dataformat.cbor.CBORGenerator.getOutputContext()Lcom/fasterxml/jackson/core/json/JsonWriteContext;
at com.amazonaws.services.kinesis.model.transform.PutRecordRequestMarshaller.marshall(PutRecordRequestMarshaller.java:85)
at com.amazonaws.services.kinesis.AmazonKinesisClient.putRecord(AmazonKinesisClient.java:1365)
Upvotes: 4
Views: 6630
Reputation: 13270
Another solution here is to make sure that your included version of Jackson and the one Amazon includes in Kinesis by default aren't conflicting.
There was a breaking change made to Jackson and if you manually include a newer version but the AWS SDK version you're using uses an older version with the breaking change then you will create a conflict when running the project. Or vice-versa.
So the solution is to either upgrade your AWS SDK or downgrade your Jackson client. I'll provide the versions of each API that worked for me with a libs.gradle excerpt:
ext.versions = [
spring: '4.3.5.RELEASE',
awsServerlessJavaContainer: '0.4',
jackson: '2.8.6'
]
ext.libs = [
dynamoDbLocal: 'com.amazonaws:DynamoDBLocal:1.11.0.1',
aws: [
dynamodb: 'com.amazonaws:aws-java-sdk-dynamodb:1.11.100',
lambda: 'com.amazonaws:aws-lambda-java-core:1.1.0',
lambdaEvents: 'com.amazonaws:aws-lambda-java-events:1.3.0',
kinesis: 'com.amazonaws:amazon-kinesis-client:1.7.3',
sns: 'com.amazonaws:aws-java-sdk-sns:1.11.115',
],
awsServerlessJavaContainer: [
spring: "com.amazonaws.serverless:aws-serverless-java-container-spring:${versions.awsServerlessJavaContainer}"
],
guava : 'com.google.guava:guava:18.0',
jackson: [
databind: "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}",
cbor: "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
],
]
Upvotes: 0
Reputation: 704
Resolved by removing Jackson Dependency from my package. Reason: Conflict between my dependency import on Jackson vs AWS SDK's dependency on Jackson. Kinesis Client uses Jackson for marshalling. I was using Jackson's latest version, which was causing dependency conflict.
Upvotes: 9