j.Stark j.Stark - 9 months ago 77
JSON Question

Error while generating json content using jersy

I'm working on jersy project when a lunch tomcat server i get this exception :

MessageBodyWriter not found for media type=application/json

This is my code :

public class ActivityResource {

private ActivityRepository activityRepository = new ActivityRepositoryStub();

public List<Activity> getAllActivities(){

return activityRepository.findAllActivities();


Answer Source

You need to add jersy-media-moxy jar in your Lib folder or add it in your pom.xml that why you have this error message

if you want to return xml content make shur that you have @XmlRootElement on your entity because jersy use JAXB to map java object to xml

public class Activity {