Fixed: MessageBodyReader not found for media type

I've been plagued with this error over the past few days:

Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json, type=class com.mycompany.customerclientmaven.Customer, genericType=class com.mycompany.customerclientmaven.Customer.
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(

This is what you get when you're running a RESTful web service client, e.g., you've created RESTful web services that expose customers, etc. Now you want to access those services. 

In your client code you have statements like this:


Everything compiles fine. Then you run the application and see the stack trace above.

Much googling later brought me to this which works out of the box:

Genson is a data-binding and streaming library for JSON. It implements the extension points MessageBodyReader and MessageBodyWriter of JAX-RS and declares its implementation with Java's service loader mechanism. That in turn allows Jersey (and other RESTful web service libraries) to automatically detect Genson and use it for JSON parsing/writing.

For Maven, it's as simple as adding this, otherwise download the JAR and add it to your classpath yourself.



Brilliant!, totally works, thanks it helped me a lot

Posted by Miguel Rueda on November 09, 2014 at 04:04 PM PST #

Just great !!.
Thanks !!

Posted by guest on November 19, 2014 at 10:47 AM PST #

Thanks, it works!

Posted by Marek on March 02, 2015 at 07:18 AM PST #

I'm new to Java and stuff like this drives me nuts. :) Thanks so much for posting it, it's helped me keep moving.

Posted by TimF on March 13, 2015 at 09:30 AM PDT #

Thanks Dude !! That was a lifesaver!!

Posted by guest on April 21, 2015 at 06:27 PM PDT #

It worked !!

Posted by guest on September 08, 2015 at 05:51 AM PDT #

thanks for this solution..

Posted by guest on November 10, 2015 at 03:22 AM PST #

thanks a lot !

Posted by guest on February 17, 2016 at 05:20 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« May 2016