. Advertisement .
..3..
. Advertisement .
..4..
The error: “Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
The reason of the error: “Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value”?
When you are attempting to convert a json string to a java object, you may get the following error.
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value at com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:45) at
The reason of why you have encountered the error ”Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value” is that you are missing jackson-annotations in the classpath. In your case, there are many JAR files in Jackson. However, they have different versions. This also is a reason which results in the above error.
How to fix error “Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value”?
Approach 1: Add this to your classpath with the same version.
To solve the ”Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value” error, you simply need to include to your classpath with the same version. Add the following three jars to your build path:
jackson-core
jackson-databind
jackson-annotations
These projects also interact with one another in that arrangement. The Jackson Core attributes are used by Jackson Annotation, and Jackson Annotation is used by the Jackson Databind.
Jackson includes a few other projects that allow it to parse data in formats other than JSON. For instance, you may also add the jackson-dataformat-cbor artifact to your classpath in order to read and write CBOR.
As a result, you must add these JAR files to your application’s classpath in order to “install” Jackson in your Java application.
Approach 2: Include this in pom.xmls
Simply add this to the POM.xml file and modify all three jars to use the same version of data-bind, annotations, and core jackson jars to deal with the problem.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
Conclusion
We hope you enjoy our article about the error. With this knowledge, we know that you can fix your error: “Exception in thread “main” java.lang.NoClassDefFoundError: com/fasterxml/jackson/annotation/JsonInclude$Value” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Leave a comment