Solving JohnzonObjectMapperFactory exception on rest-assured 4.0.0

Elias Nogueira
Jun 7 · 1 min read

The problem

Maybe you like to get up-to-date with all your libraries. Me too.

If you're using rest-assured 4.0.0 in a project in conjunction with Spring Boot you'll get this exception in any test execution:

java.lang.NoClassDefFoundError: io/restassured/path/json/mapper/factory/JohnzonObjectMapperFactory

MacOsX
Java JDK 12
Spring Book 2.1.5.RELEASE

The solution

As indicated on https://github.com/rest-assured/rest-assured/wiki/GettingStarted#java-9 you may add a dependency rest-assured-all.

In my case, I'm using Maven (I don't know how to solve it for Gradle).
Simply add the following dependency without removing the rest-assured dependency:

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured-all</artifactId>
<version>4.0.0</version>
</dependency>

That solves the problem (at least for me).

This error seems to appear only with JDK 12. I've tested with JDK 8 and the rest-assured-all was not necessary.

Happy tests!

Elias Nogueira

Written by

Senior QA Engineer, Agile Coach and Trainer