Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError for JsonErrorUnmarshallerV2 with AWS Java SDK

I'm just starting with DynamoDb and I'm a beginner with maven. I'm hitting an error when trying to run my project that I can't fix.

When I try to run the project in IntelliJ I get:

Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/transform/JsonErrorUnmarshallerV2
at com.amazonaws.services.kms.AWSKMSClient.init(AWSKMSClient.java:305)

In the top level pom I have the following dependency:

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

I've tried lots of things, e.g. including the maven dependency for KMS separately, referencing the latest versions of both the sdk and kms, and the same version of the sdk and kms. I've tried including the bom and then the sdk like this:

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-bom</artifactId>
            <version>1.10.40</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.10.40</version>
        </dependency>

I always get the same error. mvn clean and mvn install work without error, but running the application fails.

I can see that there is no definition for JsonErrorUnmarshallerV2 in the debugger, however aws-sdk-core is supposed to provide this and should be included.

How can I fix or further debug this problem?

like image 319
mark Avatar asked Dec 09 '15 10:12

mark


1 Answers

Well it turns out that

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

does not include aws-core, I needed to include that separately, i.e.

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.10.40</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-core</artifactId>
            <version>1.10.40</version>
        </dependency>
like image 124
mark Avatar answered Nov 11 '22 19:11

mark