title: How get JSON as response in jax-rs jersey web service?
body: <pre><code> package com.webservice.rest.jaxb;
  
      import javax.xml.bind.annotation.XmlRootElement;
  
      @XmlRootElement(name="employee")
      public class Employee {
      String name;
      String id;
      String location;
      float salary;
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getId() {
          return id;
      }
      public void setId(String id) {
          this.id = id;
      }
      public String getLocation() {
          return location;
      }
      public void setLocation(String location) {
          this.location = location;
      }
      public float getSalary() {
          return salary;
      }
      public void setSalary(float salary) {
          this.salary = salary;
      }
        @Override
        public String toString() {
          return "Name [Id=" + id + ", Location=" + location
              + ", Salary=" + salary  + "]";
        }
  }
  </code></pre>
  
  <p>here is My employeewebservice </p>
  
  <pre><code>  package com.webservice.rest.jaxb;
  
      import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.Produces;
      import javax.ws.rs.core.MediaType;
  
      @Path("/employee")
      public class EmployeeResource {
  
  
                @GET
                @Path("/getjson")
                @Produces({MediaType.APPLICATION_JSON})
  
                public Employee getJSon() {
                    Employee emp = new Employee();
                      emp.setName("Ankesh");
                      emp.setId("2096");
                      emp.setLocation("Pune_Kolkata");
                      emp.setSalary(2097868);
                      return emp;
                }
  
      }
  </code></pre>
  
  <p>Below Is Web .xml</p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
      xmlns="http://java.sun.com/xml/ns/javaee"   
      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"&gt; 
       &lt;display-name&gt;JaxbWithrs&lt;/display-name&gt;
       &lt;servlet&gt;
          &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
           &lt;!-- Register resources and providers under com.vogella.jersey.first package. --&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
              &lt;param-value&gt;com.webservice.rest.jaxb&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
        &lt;/servlet&gt;
        &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
        &lt;/servlet-mapping&gt;
      &lt;/web-app&gt;
  </code></pre>
  
  <p>Iam Geting following Exception</p>
  
  <blockquote>
    <p>MessageBodyWriter not found for media type=application/json,
    type=class com.webservice.rest.jaxb.Employee, genericType=class
    com.webservice.rest.jaxb.Employee.</p>
  </blockquote>
  
  <p>Below is screenshot of my lib  directory</p>
  
  <p>Please let me know if i missed anything!</p>