In this short tutorial, we will explain what causes Jackson to raise the error java.lang.noclassdeffounderror: com/fasterxml/jackson/core/util/jacksonfeature.

First, we will highlight the leading cause of this error. Then, we will exemplify how to reproduce and solve it.

Cause of the Error

Typically, java.lang.noclassdeffounderror is telling us that the classloader fails to find a required class at runtime.

More specifically, in this case, the missing class is com/fasterxml/jackson/core/util/jacksonfeature.

Please note that JacksonFeature is added in 2.12.0. So, one of the common causes of this error is using an older version that does not include the JacksonFeature class.

Another reason would be having different versions in the classpath. The conflict between versions can override the appropriate dependency and cause Jackson to throw the error.

Reproducing java.lang.noclassdeffounderror: com/fasterxml/jackson/core/util/jacksonfeature

To exemplify the error, we will assume that we have a Spring Boot application.

By default, Spring Boot parent POM includes Jackson dependencies. So, let’s see what happens if we add another version manually.

For instance, let’s add the 2.10.0 version (which is older than 2.12.0):

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

Now, let’s run the application and view the logs:

    
        Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/util/JacksonFeature
            at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:673) ~[jackson-databind-2.13.5.jar:2.13.5]
            at com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:576) ~[jackson-databind-2.13.5.jar:2.13.5]
            ...
        Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.util.JacksonFeature
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
            ... 66 common frames omitted
    

As we can see, the application fails with java.lang.NoClassDefFoundError.

The older version of jackson-core overrides the default one provided by Spring Boot. Hence, the error.

 Overriding a managed version can cause java.lang.noclassdeffounderror

Solutions

The easiest solution would be removing the older version of Jackson from the classpath.

Alternatively, upgrading Jackson to a newer version that includes JacksonFeature will fix the issue.

Conclusion

To summarize, first, we explained what causes Jackson to fail with java.lang.ClassNotFoundException: com.fasterxml.jackson.core.util.JacksonFeature.

Then, we explored different ways of solving the issue.