• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Cannot run code due to java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonMerge

 
Ranch Hand
Posts: 143
5
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some test code in Intellij Idea 2018, which has multiple pom files. When I run any testng annotated test, I get an error which says "no tests were found". It looks like the problem is due to this part of the exception stack trace:

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

I googled for a solution and found this - https://github.com/FasterXML/jackson-annotations/issues/119 and this https://stackoverflow.com/a/46406070. It looks like this issue is caused when we don't have the same version of these jars in the project.

1) jackson-core (2.8.8)

2) jackson-databind (2.9.2)

3) jackson-annotations (2.8.5)

As you can see, I don't have the same version for all the jars. I looked at all the poms in my project and did not find any place where all these dependencies are added. I was hoping to simply set the version number there. Should I simply add all dependencies in my parent pom file or do something else ?

How do I resolve this issue without harming the project ? How do I find out why these jars are not of the same version ?

 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With mvn dependency:tree you can see the entire dependency tree. Eclipse even has a built-in view for this if you open pom.xml.

Adding jackson as a dependency of your own application can work, although it's not the cleanest way if you don't need it directly.
 
Tom Joe
Ranch Hand
Posts: 143
5
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:With mvn dependency:tree you can see the entire dependency tree. Eclipse even has a built-in view for this if you open pom.xml.

Adding jackson as a dependency of your own application can work, although it's not the cleanest way if you don't need it directly.



Could you please tell me why adding jackson is not a clean way in this case ? Any idea on how I can use dependency viewer in intellij idea community version ?
I have 2018.1 and I don't see the option for this - https://www.jetbrains.com/help/idea/dependency-viewer.html.

 
Rob Spoor
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In an ideal situation, your POM only lists the dependencies you need directly. If a dependency X is only part of the implementation detail of one of your dependencies Y and you include it as well, then you will be stuck with X if a newer version of Y drops the dependency on X. However, unfortunately, sometimes you have little choice...

As for the IntelliJ question, I don't use it so I can't help you with that.
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Any idea on how I can use dependency viewer in intellij idea community version ?


I will add this thread to the IntelliJ forum.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic