java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge

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

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

上一篇: Java How to download a file from the Internet
下一篇: Spring Boot + Spring Data + Elasticsearch example
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号