Skip to content
Advertisement

JAX RS MessageBodyWriter not found for media type=application/json

I am creating Rest client using JAX RS Jersey 2. The client works but only in my IDE (IntellIJ IDEA), when I build it with Maven, using maven-assembly-plugin and run the jar it doesn’t work anymore.

I get MessageBodyWriter not found for media type=application/json error.

I have tried adding more dependencies that people suggested in other posts but I don’t think a dependency is a problem since it runs in the IDE.

Here is the code that throws the exception

JavaScript

After debugging, when I replace transactions.get(0) with an empty string “”, it works.

Here is the pom.xml for maven

JavaScript

Am i missing something? Really bothers me that it runs in the IDE but not when built with Maven since I build it with dependencies.

Advertisement

Answer

Check if you have class com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider in your resulting JAR. If not, add following dependency:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement