Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoSuchMethodException in MaxMind GeoIp dependency jackson-databind built with mvn shade

I'm trying to run MaxMind's geoIP in a spark task, but I'm getting a NoSuchMethodException from a maxmind call to a jackson-databind library. I've removed all other versions of jackson-databind using mvn exclusions, yet the error persists after a mvn clean. What am I missing?

No dependency conflicts:

mvn dependency:tree -Dverbose -Dincludes=com.fasterxml.jackson.core:jackson-databind ... [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ sift-etl --- [INFO] com.sift.etl:sift-etl:jar:0.1.6 [INFO] \- com.maxmind.geoip2:geoip2:jar:2.6.0:compile [INFO] \- com.maxmind.db:maxmind-db:jar:1.2.0:compile [INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.7.0:compile

Error:

Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.node.ArrayNode.<init>(Lcom/fasterxml/jackson/databind/node/JsonNodeFactory;Ljava/util/List;)V at com.maxmind.db.Decoder.decodeArray(Decoder.java:272)

Edit: I have a ton of org.codehaus.jackson, do I need to exclude these as well? How can I resolve the differences in namespaces?

Edit: This is built into a scala based project that runs in Apache Spark. The jar is compiled into a shaded jar using maven-shade-plugin 2.4

Edit: Here's the complete output for jar tvf on the shaded jar: https://drive.google.com/file/d/0B2ZVKNsRXgTbeUdEU2ZhM2J3dmc/view?usp=sharing

Here's the result of a grep for jackson-databind: 0 Mon Jan 25 09:53:54 PST 2016 META-INF/maven/com.fasterxml.jackson.core/jackson-databind/ 151 Mon Jan 25 09:53:54 PST 2016 META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.properties 5192 Mon Jan 25 09:53:54 PST 2016 META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml

and ArrayNode: /usr/lib/jvm/sift-jdk1.8.0_66/bin/jar -tvf target/sift-etl-0.1.6-shaded.jar | grep ArrayNode 15060 Sat Jan 23 01:33:14 UTC 2016 shaded/parquet/org/codehaus/jackson/node/ArrayNode.class 1309 Sat Jan 23 01:33:18 UTC 2016 org/apache/lucene/index/DocumentsWriterDeleteQueue$QueryArrayNode.class 1645 Sat Jan 23 01:33:18 UTC 2016 org/apache/lucene/index/DocumentsWriterDeleteQueue$TermArrayNode.class 18145 Sat Jan 23 01:33:20 UTC 2016 com/fasterxml/jackson/databind/node/ArrayNode.class 1058 Sat Jan 23 01:33:22 UTC 2016 org/apache/commons/configuration/plist/XMLPropertyListConfiguration$ArrayNode.class

Initializing and querying the maxmind GeoIP DB runs successfully in tests. The error only occurs in production when run as a spark task -- after it has been packaged using maven-shade.

maven-shade plugin config: http://pastebin.com/QzrhM5Ee

Is it meaningful that the shaded jar doesn't contain the jackson-databind jar, but all of the *.class files within the jar?

like image 727
bhan Avatar asked Jan 23 '16 01:01

bhan


1 Answers

The version of the ArrayNode constructor that takes a JsonNodeFactory and a List<JsonNode> as parameters was removed as of version 2.2.0 of com.fasterxml.jackson.core:jackson-databind jar, so this looks like a bug in the maxmind-db library, since it is pulling in version 2.7.0 of jackson-databind but (at least indirectly) calling an obsolete method.

If possible, you could try downgrading your jackson-databind dependency by explicitly including in your pom file like so:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.1.0</version>
</dependency>
like image 193
palimpsestor Avatar answered Oct 20 '22 11:10

palimpsestor