Solution
MessageBodyWriter not found for media type=application/json : this error occurs, because you have missing jersey-media-json-jackson dependency.
To resolve the issue please add the required library to your project. Because Maven and Gradle are two the most popular build automation tools I provide the dependency entry for each one.
Maven
To add the missing dependency just go to the Maven Repository and choose appropriate version or copy past the following code:
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>2.32</version> </dependency>
Gradle Version
When you are using Gradle you can choose the newest Gradle version. Check the link to find the newest one. When I was writing this post it was the v7.4.2.
... compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.32' ...
Select Version
Please verify which version you should add to your project. You can check the available version in Central Maven Repository.
![[SOLVED] MessageBodyWriter not found for media type=application/json - Check Simple 1 Min Solution! 2 MessageBodyWriter not found for media type=application/json](https://bigdata-etl.com/wp-content/uploads/2022/03/Zrzut-ekranu-2022-03-22-o-17.07.53.png)
Summary
If we use third party libraries, we often encounter the problem of incompatibility of libraries. When we change / raise the version of one library, it may turn out that it no longer contains a built-in dependency. Then, unfortunately, we have to find the missing library and attach it ourselves.
Maven Dependency Tree
In the process of finding the missing dependency, we can use the dependency tree command:
mvn dependency:tree
The snippet from execution the above column looks like the following code:
[INFO] com.bigdataetl.spark:jar:0.0.0-SNAPSHOT [INFO] +- net.lingala.zip4j:zip4j:jar:2.6.1:compile [INFO] +- info.batey.kafka:kafka-unit:jar:1.0:test [INFO] | +- junit:junit:jar:4.11:compile [INFO] | | \- org.hamcrest:hamcrest-core:jar:1.3:compile [INFO] | \- org.apache.zookeeper:zookeeper:jar:3.4.10:provided [INFO] +- org.apache.kafka:kafka-clients:jar:0.11.0.3:compile [INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.2.6:compile [INFO] | \- org.slf4j:slf4j-api:jar:1.7.25:compile [INFO] +- org.apache.kafka:kafka_2.11:jar:0.11.0.3:test [INFO] | +- net.sf.jopt-simple:jopt-simple:jar:5.0.3:test [INFO] | +- com.yammer.metrics:metrics-core:jar:2.2.0:test [INFO] | +- org.slf4j:slf4j-log4j12:jar:1.7.25:provided [INFO] | \- com.101tec:zkclient:jar:0.10:test ... etc...
If you enjoyed this post please add the comment below and share this post on your Facebook, Twitter, LinkedIn or another social media webpage.
Thanks in advanced!