title: MessageBodyWriter not found for media type=text/plain, type=class TestRest.Track, genericType=class TestRest.Track
body: <p>I am getting the following error while requesting JSON format and string is successfully returned.</p>
  
  <blockquote>
    <p>MessageBodyWriter not found for media type=text/plain, type=class TestRest.Track, genericType=class TestRest.Track</p>
  </blockquote>
  
  <p>I tried to lower down the jackson jar but it did not fix the problem.</p>
  
  <p>I am using below jersey and jackson version and get the error.</p>
  
  <pre><code>1. javax.ws.rs-api-2.0.1.jar
  2. aopalliance-repackaged-2.5.0-b32.jar
  3. hk2-api-2.5.0-b32.jar
  4. hk2-locator-2.5.0-b32.jar
  5. hk2-utils-2.5.0-b32.jar
  6. javassist-3.20.0-GA.jar
  7. javax.annotation-api-1.2.jar
  8. javax.inject-2.5.0-b32.jar
  9. javax.servlet-api-3.0.1.jar
  10. jaxb-api-2.2.7.jar
  11. jersey-guava-2.25.1.jar
  12. org.osgi.core-4.2.0.jar
  13. osgi-resource-locator-1.0.1.jar
  14. persistence-api-1.0.jar
  15. validation-api-1.1.0.Final.jar
  16. jersey-client.jar
  17. jersey-common.jar
  18. jersey-container-servlet.jar
  19. jersey-container-servlet-core.jar
  20. jersey-media-jaxb.jar
  21. jersey-server.jar
  22. jackson-annotations-2.9.0.jar
  23. jackson-core-2.9.9.jar
  24. jackson-databind-2.9.9.1.jar
  </code></pre>
  
  <p>I have tried to lower down the jackson version but the problem still exist.
  Below is my web.XML configuration file.</p>
  
  <pre><code>WEB.XML
  &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;PSG&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
    &lt;welcome-file&gt;login&lt;/welcome-file&gt;
   &lt;/welcome-file-list&gt;
  
   &lt;servlet&gt;
  &lt;servlet-name&gt;spring-dispatcher&lt;/servlet-name&gt;
  &lt;servlet-class&gt;
  org.springframework.web.servlet.DispatcherServlet
  &lt;/servlet-class&gt;
  &lt;init-param&gt;
  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring-dispatcher-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;spring-dispatcher&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
   &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt; 
  
  &lt;listener&gt;
      &lt;listener-class&gt;
        org.springframework.security.web.session.HttpSessionEventPublisher
      &lt;/listener-class&gt;
  &lt;/listener&gt;
  
   &lt;context-param&gt;    
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;    
    &lt;param-value&gt;/WEB-INF/security-config.xml 
      /WEB-INF/spring-database.xml
    &lt;/param-value&gt;    
   &lt;/context-param&gt; 
  &lt;!-- Logging listener --&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.util.Log4jConfigListener&lt;/listener-class&gt;
    &lt;/listener&gt;
    &lt;context-param&gt;
      &lt;param-name&gt;log4jConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:log4j.properties&lt;/param-value&gt;
      &lt;!-- You can also define yourpath with a environment variable and use it like file:${env_variable_path}/log4j.properties  --&gt;
    &lt;/context-param&gt;
  &lt;filter&gt;    
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;    
    &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;    
   &lt;/filter&gt;    
  
   &lt;filter-mapping&gt;    
    &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;    
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;    
  
   &lt;/filter-mapping&gt; 
  
  &lt;session-config&gt;
  &lt;session-timeout&gt;10&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  
        &lt;servlet&gt;
  
          &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;classpath:applicationcontext.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  
      &lt;/servlet&gt; 
     &lt;servlet&gt;
  &lt;servlet-name&gt;JAVA API&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
  &lt;init-param&gt;
  &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
  &lt;param-value&gt;TestRest&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;JAVA API&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;!-- 
     &lt;context-param&gt;
          &lt;param-name&gt;resteasy.scan&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;resteasy.scan.providers&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;resteasy.scan.resources&lt;/param-name&gt;
          &lt;param-value&gt;false&lt;/param-value&gt;
      &lt;/context-param&gt;
       --&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Below is my java class</p>
  
  <pre><code>TACK.JAVA
  package TestRest;
  
  import org.jboss.logging.Logger;
  
  
  
  public class Track {
      private static final Logger logger = Logger.getLogger(Track.class.getName());
      String title;
      String singer;
  
      public Track(){}
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getSinger() {
          return singer;
      }
  
      public void setSinger(String singer) {
          this.singer = singer;
      }
  
      @Override
      public String toString() {
          String Concatst= "Track [title=" + title + ", singer=" + singer + "]";
          logger.info("------------"+Concatst);
          return Concatst;
      }
  
  }
  </code></pre>
  
  <p>JAVASERVICE CLASS WHERE I CALLED TRACK>JAVA CLASS.</p>
  
  <pre><code>JSONSERVICE.JAVA
  package TestRest;
  
  import javax.ws.rs.Consumes;
  import javax.ws.rs.GET;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  
  import org.jboss.logging.Logger;
  
  import TestRest.Track;
  
  @Path("/json/metallica")
  public class JSONService {
      private static final Logger logger = Logger.getLogger(Track.class.getName());
      @GET
      @Path("/get")
      @Produces(MediaType.TEXT_PLAIN)
      public Track getTrackInJSON() {
  
          Track track = new Track();
          track.setTitle("Enter Sandman");
          track.setSinger("Metallica");
          logger.info(track);
          return track;
  
      }
  
      @POST
      @Path("/post")
      @Consumes(MediaType.APPLICATION_JSON)
      public Response createTrackInJSON(Track track) {
  
          String result = "Track saved : " + track;
          return Response.status(201).entity(result).build();
  
      }
      }
  </code></pre>