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

2

17
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?

Ewe answered 9/7, 2020 at 2:27 Comment(4)
You can exclude the jackson-databind dependency from springfox-swagger2 and see if that works? <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.10.5</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </exclusion> </exclusions> </dependency>Otoplasty
No that does not solve. Seems application search searching it while running. 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 at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:132) at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellEwe
Can you please provide the complete trace?Otoplasty
Is there any update on this issue?Talamantes
H
33

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!

Handwoven answered 11/4, 2021 at 2:43 Comment(0)
C
9

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
Crosscut answered 22/9, 2021 at 11:19 Comment(1)
Fixed it for me!Grath

© 2022 - 2025 — McMap. All rights reserved.