12

When I am migrating from spring 4.3.4 to 4.3.7 I am facing NoclassDefined error after adding Jackson-core dependency

Caused By: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/DefaultIndenter

I tried to add jackson-core

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

dependency also but no luck

Any one who can shed some light on this would be appreciated.

Thanks Vinod

Vinod Sidiginamale
  • 241
  • 1
  • 5
  • 9
  • 3
    The `DefaultIndenter` class was introduced in Jackson 2.5. Perhaps some other part of your project is bringing in a dependency on an earlier version lacking the class. It might be a transitive dependency through some library. Try running `mvn dependency:tree` and looking for older Jackson versions in the output. – Chris Nauroth Jul 12 '17 at 16:21
  • give the snapshot of your project dependencies – Serhii Povísenko Jul 12 '17 at 16:54
  • @Sergey/Chris we have multi module environment where we are inheriting dependencies from other pom's as well.Everywhere I can see that the dependency version for Jackson-core is same one more time I will clean the repositories and update you guys .Thanks for your prompt response. – Vinod Sidiginamale Jul 13 '17 at 07:52

3 Answers3

1

I had this problem, with Spring 4.3.22.RELEASE and jackson-databind 2.2.3, I only had to upgrade to 2.9.8 and problem solved.

OJVM
  • 1,403
  • 1
  • 25
  • 37
0

If someone else found this through Google and if You are using Spring Boot, here is what solved the problem for me. Try setting the parent of Your pom file (i.e. Maven project):

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.2.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

This will set the spring-boot-starter version to 2.0.2, and not the 1.x, which was default (at least for me).

Following the comment of Chris Nauroth, I've used the mvn dependency:tree and saw that the 1.x version of Spring Boot used the 2.4.x version of Jackson, whereas spring-boot-starter version 2.x uses Jackson 2.5 or higher.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Aleksandar
  • 3,558
  • 1
  • 39
  • 42
0

This worked for me!

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.0.2.RELEASE</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>