Search code examples
mavendependency-managementjackson-modules

java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value


I am running into this error while trying to compile my maven project during the test execution. From what I understood after insane amount of googling is that this is because of some conflicting version of jackson-core thats in the classpath.

Here is what I find in the dependency hierarchy

enter image description here

I am not sure how to proceed from here, given that only one version appears to be in the effective resolved dependecies

If I skip tests and run the install the build succeeds but fails if I run a test or start a server during run time

If I navigate the repository I see the following versions

2.1.1   2.1.2   2.3.3   2.4.3   2.5.1   2.5.3   2.8.2

Should I delete all of them ?

This is a multimodule project and every moule is bringing some vrsion of this dependency. Does this matter?


Solution

  • You are bringing in multiple versions of jackson dependencies across all these projects. Jackson isn't designed to be able to mix and match across the versions.

    You should should define dependency management at the Parent POM level to manage the jackson artifact versions in use within your own projects.

    https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management

    Depending if you have access to these other Jars that are using their own jackson versions you may need to add exclusions to stop maven from using their jackson versions.

    https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html

    I'd guess the conflict will be between the core and annotation versions in use but realistically you will have issues with the other jackson artifacts being on separate versions like the jaxb-annotations, databind etc.