ppanero
ppanero

Reputation: 327

DynamoDB Geo Object Mapper Class Not Found

I have been trying to use the dynamodb-geo library in my project (Android). After reading everything possible around the interent I noticed that the lib jars are not included in the classpath, I did it and got to the codehaus Object Mapper class not found exception. Then I sustitute the dependencies in the pom to add fasterxml and change the corresponging imports. After that I have packaged it (mvn clean package) and put the corresponding jar in the libs folder of my android project, set it up in gradle and "play".

However, I still get the annoying "Class not found".

The pom of the dynamodb geo contains:

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.3</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.8.3</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.8.3</version>
    </dependency>

And my gradle file in android contains:

compile files('libs/dynamodb-geo-1.1.0.jar')

But I am still getting:

10-17 17:27:33.134 5139-5363/com.fivesigmagames.sdghunter E/AndroidRuntime: FATAL EXCEPTION: Thread-32098
    Process: com.fivesigmagames.sdghunter, PID: 5139
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/fasterxml/jackson/databind/ObjectMapper;
        at com.amazonaws.geo.util.GeoJsonMapper.<clinit>(GeoJsonMapper.java:26)
        at com.amazonaws.geo.dynamodb.internal.DynamoDBManager.putPoint(DynamoDBManager.java:125)
        at com.amazonaws.geo.GeoDataManager.putPoint(GeoDataManager.java:132)
        at com.fivesigmagames.sdghunter.repository.aws.AWSShareItemRepository$1.run(AWSShareItemRepository.java:58)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.fasterxml.jackson.databind.ObjectMapper" on path: DexPathList[[dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-unity-classes_bf479e7b8b71b5703bea6af2dcab41a7dfc4e91a-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-support-annotations-24.2.1_7a5f3f7e74247119444f4d43b2c522de9eab70fb-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-s2-geometry-java_4a01ca5c6a6c529340eae8f7f80c06b632fdefb5-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-retrofit-2.1.0_95833411f91cbb8e9410129091d258a780b3748c-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-okio-1.8.0_0cb7cee6746d84f62570817f36b8feb9fcf01356-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-okhttp-3.3.1_f8edaf579e8e4a295d221f114889d70d3e62eb9f-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-mapbox-java-services-1.3.1_a50eb5179d7320fcdc538c586ebd2f231b152887-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-logging-interceptor-3.3.1_699d973b2d0ba8bcd453fd52df4c55554a3d27f5-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-internal_impl-24.2.1_f38e546d683a020056b2318e9388188d85136c2f-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-internal_impl-24.2.1_8f4ea427bad833b1812bc9e939084c687a54e0d0-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-internal_impl-24.2.1_3609d9e6e631ae1ef0b5261e8250a3cf6f1193cf-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-internal_impl-24.2.1_280e40067a7d8e7f7f2bc98507cf0b17f26db6bf-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-internal_impl-24.2.1_008f1eca59ba22cef5240a40ab0f74834de26c4c-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-guava-r09_4880220368cf85c4cfb2f46fdedb8912a6629e2a-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-guava-18.0_e11ced1631feb7c9800790c98fd765d3bed1b86c-classes.dex", dex file "/data/data/com.fivesigmagames.sdghunter/files/instant-run/dex/slice-gson-2.7_792e0

If I manually (thourgh gradle) add the three jackson dependencies I get a "duplicate" entry error and it does not compile.

Thanks for the help!

Upvotes: 0

Views: 290

Answers (1)

Peter Fennema
Peter Fennema

Reputation: 1690

I've been struggling with this about 7 months ago. The dynamodb-geo jar has a dependency with an old version of the java aws-sdk (1.5.5). This 1.5.5 version uses org.codehaus package names for the Jackson libs.

Later Jackson has modified it's packages names from org.codehaus to com.fasterxml. More recent versions of the java aws-sdk have been updated to use these new package names, but dynamodb-geo still depends on 1.5.5 . So you can not deploy this old jar in a newer java aws-sdk environment.

Best solution is to create a new jar for dynamodb-geo yourself, as you are already trying. But you do not need to add dependencies with Jackson yourself, because these are provided by the aws sdk. You can fork the aws dynamodb-geo repository on github, update the aws-java-sdk.version property in the pom.xml, fix the compile errors and build your own jar with Maven.

I have created a fork on Github that does exactly this. Using this fork you can easily create your own jar.

I have reported this issue to AWS and provided a pull request on Github. Unfortunately the library is not maintained at all, which made me decide not to use it.

Upvotes: 0

Related Questions