I am trying with simple Jersey + JSON example but I get following error
message body writer for Java class com.test.jsonexample and MIME media type application/json w
I too have same issue with 1.19.4 jersey. It got fixed by adding
compile group: 'com.fasterxml.jackson.jaxrs', name: 'jackson-jaxrs-json-provider', version: '2.10.0.pr1'
to gradle dependency.
Thanks, Praveen R.
If you are not tied to jackson you could try Genson library http://owlike.github.io/genson/. You only need the lib in your classpath and every thing should work without any additional code. You wont even have to use POJOMappingFeature in web.xml nor add @XMLRootElement on your pojo!
You can also inject instances of Genson with specific configurations using jersey mechanisms (ContextResolver).
I know this is an old question, but I came across this issues and tried all the above solutions, but unfortunately, none of them helped me. What I found was, that the class MediaType was defined in two different jars, and when building the jar, it took the class that was defined in the other class (in my case, glassfish jar). After removing the other jar (you can also exclude the specific part), the problem was solved