Fahad Mullaji Fahad Mullaji - 1 year ago 305
Java Question

MessageBodyWriter not found for media type=application/json

I am facing issues while consuming JAX-RS services as JSON.

Below I have added my code.

This is my service class:

//Sets the path to base URL + /hello
public class Hello {

public Student getStudent() {

Student s = new Student();
s.first_name = "Test First Name !!!";
s.last_name = "Test Last Name!!!";

return s;

class which I am trying to get from service:

public class Student implements Serializable {

public String first_name;
public String last_name;

public String getFirst_name() {
return first_name;

public void setFirst_name(String first_name) {
this.first_name = first_name;

public String getLast_name() {
return last_name;

public void setLast_name(String last_name) {
this.last_name = last_name;

public Student()
first_name = "Fahad";
last_name = "Mullaji";

Web XML on service side.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<servlet-name>Jersey REST Service</servlet-name>
<!-- Register resources and providers under com.vogella.jersey.first package. -->

<servlet-name>Jersey REST Service</servlet-name>

I don't know how to fix this issue.
I am using SOAP UI for testing JSON response but I guess that it should not matter.

Many places I read that I need to add the code below. But I don't know where. I am not using Maven for building.


Server is looking for function to parse
object to JSON but it is not able to find function or jar file for it.
I have added jar of Genson, Moxy, RESTEasy and Jackson but I think that's the problem.
I think I am missing mapping somewhere.

Answer Source

Well, I could not make the above web project working. But I kept on doing research on JAX-RS and I came across Stormpath's tutorial. I think whoever is trying to learn how REST, JSON and Jersey work together should watch this.

Please see links below for their presentation and sample REST project on GitHub .



Now I can compare above project and see what all things I did wrong.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download