NoClassDefFoundError com/fasterxml/jackson/core/TreeNode -- json schema validation

java, json, jsonschema

Solution

If I recall correctly `jackson-databind` has a transitive dependency to `jackson-core` where `TreeNode` should be. Check your `.m2` folder for the presence of:

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

and if it's there I agree that you might have a classpath problem, such as a previous version of `jackson-core` first in the classpath.

Cheers,

Problem

Getting the below mention exception in json-schema-validator 2.1.7 jar: ``` java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/TreeNode at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.lang.ClassLoader.defineClass(ClassLoader.java:466) ``` I am using: - json-schema-validator 2.1.7 jar - json-schema-core 1.1.8 jar - jackson-coreutils 1..0 jar - jackson-databind-2.2.2 jar Code snippet is given below: ``` System.out.println(" inside json validation -- 0"); JsonNode data = JsonLoader.fromString(responseString); System.out.println(" inside json validation -- 1"); JsonNode jsonSchema = JsonLoader.fromResource(schemafilePath); System.out.println(" inside json validation -- 2"); JsonSchemaFactory factory = JsonSchemaFactory.byDefault(); System.out.println(" inside json validation -- 3"); JsonSchema schema = factory.getJsonSchema(jsonSchema); System.out.println(" inside json validation -- 4"); ProcessingReport report = schema.validate(data); ```

Original source