Reputation: 451
I have developed a REST service (GET) using Jersey. I want to return the response as application/xml. I get an exception when I annotate the following whereas when I change it to MediaType.APPLICATION_JSON, service works and returns the response as JSON. @GET @Produces(MediaType.APPLICATION_XML)
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyWriter not found for media type=application/xml
Many blogs have advised to include a dependency to jersey-media-jaxb but I have another service which is successfully returning XML response without that dependency. The only difference is that service is a POST end-point whereas the one which is currently not working is a GET end-point.
Upvotes: 0
Views: 900
Reputation: 1
If the annotation @XmlRootElement(name = "name") not mentioned in your class, try to add it. it worked for me!
Upvotes: 0