Run a Jackson related project and hits the following JsonMerge not found error.

Console

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge
	at com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.<clinit>(JacksonAnnotationIntrospector.java:50) ~[jackson-databind-2.9.0.pr1.jar:2.9.0.pr1]
	at com.fasterxml.jackson.databind.ObjectMapper.<clinit>(ObjectMapper.java:292) ~[jackson-databind-2.9.0.pr1.jar:2.9.0.pr1]
	at com.hostingcompass.core.utils.PrintUtils.<clinit>(PrintUtils.java:9) ~[main/:na]
	at com.hostingcompass.app.run.TurtleApp.run(TurtleApp.java:25) ~[main/:na]
	at com.hostingcompass.app.Main.run(Main.java:42) [main/:na]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
	at com.hostingcompass.app.Main.main(Main.java:34) [main/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77]
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na]
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.annotation.JsonMerge
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_77]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_77]
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_77]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_77]
	... 17 common frames omitted

Solution

Note
Review the error message above, the project is using jackson-databind-2.9.0.pr1

To fix it, downgrade Jackson to version 2.8.x, the latest 2.9.0.pr1 is not stable yet. For Gradle, uses dependencyInsight to find out the jackson-databind relationship.

Terminal

$ gradle dependencyInsight --configuration compile --dependency jackson-databind

com.fasterxml.jackson.core:jackson-databind:2.9.0.pr1 (conflict resolution)

com.fasterxml.jackson.core:jackson-databind:2.8.2 -> 2.9.0.pr1
\--- com.maxmind.geoip2:geoip2:2.8.0
     \--- compile

com.fasterxml.jackson.core:jackson-databind:2.8.7 -> 2.9.0.pr1
\--- compile

com.fasterxml.jackson.core:jackson-databind:[2.7.0,) -> 2.9.0.pr1
\--- com.maxmind.db:maxmind-db:1.2.1
     \--- com.maxmind.geoip2:geoip2:2.8.0
          \--- compile

To fix it, exclude the jackson-databind from com.maxmind.geoip2 :

build.gradle

dependencies {
    compile "com.fasterxml.jackson.core:jackson-databind:2.8.7"
    compile ('com.maxmind.geoip2:geoip2:2.8.0'){
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
    }
}

References

  1. ClassNotFoundException for JsonMerge #119
  2. Gradle – Display project dependency