Obtaining "MessageBodyWriter not found for media type=application/json" trying to send JSON object through JAX-RS web service Obtaining "MessageBodyWriter not found for media type=application/json" trying to send JSON object through JAX-RS web service json json

Obtaining "MessageBodyWriter not found for media type=application/json" trying to send JSON object through JAX-RS web service


Try adding Genson to your classpath, it will automatically enable JSON support.

Genson is a data-binding and streaming library for json and java/scala. It implements the extension points MessageBodyReader/Writer of JAX-RS, allowing jersey to automatically detect Genson and use it for Json parsing/writing.

You can find some more infos about Gensons integration with JaxRS (jersey & cie).


Jersey supports 'autodiscoverable' features and JSON support is one of them. In order to enable it, you need to add a compatible library to your path, according to the docs

However, while the recommended jersey-media-json-processing library has not been recognized in my case for some reason, jersey-media-moxy has:

<dependency>    <groupId>org.glassfish.jersey.media</groupId>    <artifactId>jersey-media-moxy</artifactId>    <version>2.15</version></dependency>

2.15 has been the latest version at the time of writing. Visit the maven central artifact page to find the current version.


Register the JacksonJsonProvier class with the client config and then create the Client object, this worked for me. Below is the code.

    ClientConfig config = new ClientConfig();    config.register(JacksonJsonProvider.class);    Client client = ClientBuilder.newClient(config);