Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase

current version jackson-databind-2.9.10.1.jar
need to upgrade jackson-databind-2.11.1.jar

I could not find ToStringSerializerBase class in new version of jackson updated jar

org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.datatype.jsr310.JavaTimeModule]: Unresolvable class definition; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase

internal dependencies i found

<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger2</artifactId>
     <version>2.10.5</version>
</dependency>

Any idea how can I solve this?

like image 387
ssp Avatar asked Jul 09 '20 02:07

ssp


2 Answers

I had a similar error with Spring vs. Jackson, and solved it, see below.

  1. I had a lot of dependencies on Spring stuff, and the below dependencies on Jackson:
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.9.9</version>
        </dependency>

I ran mvn dependency:tree|grep jackson and saw clashing versions:

[INFO] |     +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile
[INFO] |     +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile
[INFO] |     \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.9:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.4:compile
[INFO] \- com.fasterxml.jackson.core:jackson-core:jar:2.9.9:compile
  1. So I changed a version of Jackson I directly imported into my pom.xml to match Spring's one and all worked smoothly:
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.11.4</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.11.4</version>
        </dependency>

Hope this helps. Enjoy!

like image 118
Eugene Gr. Philippov Avatar answered Oct 08 '22 05:10

Eugene Gr. Philippov


ToStringSerializerBase is present in version 2.12 of jackson-databind

POM dependecy

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

ToStringSerializerBase is present in Jar

(base) rohiagra-mac:faw-qa-api rohiagra$ jar -tvf target/faw-qa-api-1.0-SNAPSHOT.jar | grep "ToStringSerializerBase"
  3347 Sun Nov 29 14:46:22 IST 2020 com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.class
like image 6
Rohit Agrawal Avatar answered Oct 08 '22 04:10

Rohit Agrawal