Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:19:13+00:00 2026-06-14T17:19:13+00:00

Am using Jersey 1.15, JDK 1.6, Tomcat 7, Maven 2.2.1 to create a simple

  • 0

Am using Jersey 1.15, JDK 1.6, Tomcat 7, Maven 2.2.1 to create a simple Restful Web Service that should return a JSON String from a POJO that I mapped.

Here’s my pojo:

package com.myservice.domain;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Person {
   private String firstName;
   private String lastName;

  // Getters & Setters
}

my webservice:

package com.myservice.resource;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.myservice.domain.Person;

@Path("/service")
public class MyService {

    @GET
    @Path("showPerson")
    @Produces(MediaType.APPLICATION_JSON)
    public Person getPerson() {
       Person person = new Person();
       person.setFirstName("John");
       person.setLastName("Doe");
       return person;
    }
}

Here’s my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0    
         http://maven.apache.org/xsd/maven-4.0.0.xsd">

         <modelVersion>4.0.0</modelVersion>
         <groupId>com.myservice</groupId>
         <artifactId>myservice</artifactId>
         <version>0.0.1-SNAPSHOT</version>
         <packaging>war</packaging>
         <name>My Web Service</name>

         <dependencies>
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.8.2</version>
                 <scope>test</scope>
             </dependency>

             <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-servlet</artifactId>
                <version>1.15</version>
                <scope>runtime</scope>
             </dependency>

            <dependency>
               <groupId>com.sun.jersey</groupId>
               <artifactId>jersey-server</artifactId>
               <version>1.15</version>
            </dependency>

            <dependency>
                  <groupId>com.sun.jersey</groupId>
                  <artifactId>jersey-core</artifactId>
                  <version>1.15</version>
            </dependency>

            <dependency>
                 <groupId>com.sun.jersey</groupId>
                 <artifactId>jersey-json</artifactId>
                 <version>1.14</version>
            </dependency>

           <dependency>
                <groupId>com.sun.jersey.contribs</groupId>
                <artifactId>jersey-multipart</artifactId>
                <version>1.14</version>
           </dependency>

           <dependency>
               <groupId>org.codehaus.jackson</groupId>
               <artifactId>jackson-jaxrs</artifactId>
               <version>1.9.9</version>
           </dependency>
    </dependencies>

     <build>
          <finalName>myservice</finalName>
          <plugins>
                <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                       <source>1.6</source>
                       <target>1.6</target>
                  </configuration>
                </plugin>
          </plugins>
     </build>
</project>

My web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         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"
         version="3.0"
         metadata-complete="true">
     <display-name>My Web Service</display-name>
     <servlet>
       <servlet-name>Jersey REST Service</servlet-name>
       <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
         <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.myservice.resource</param-value>
         </init-param>
         <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
     <servlet-mapping>
          <servlet-name>Jersey REST Service</servlet-name>
          <url-pattern>/rest/*</url-pattern>
      </servlet-mapping>
</web-app>

After deploying to tomcat, when I try to invoke the web service like this:

curl -X GET http://localhost:8080/myservice/rest/service/showPerson

I get the following error:

Nov 20, 2012 10:40:06 AM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: A message body writer for Java class com.myservice.domain.Person, 
and Java type class com.myservice.domain.Person, 
and MIME media type application/json was not found

Nov 20, 2012 10:40:06 AM com.sun.jersey.spi.container.ContainerResponse write
SEVERE: A message body writer for Java class com.myservice.domain.Person,
and Java type class com.myservice.domain.Person, and MIME media type 
application/json was not found

Nov 20, 2012 10:40:06 AM com.sun.jersey.spi.container.ContainerResponse write 
SEVERE: The registered message body writers compatible with the 
MIME media type are: */* ->

     com.sun.jersey.core.impl.provider.entity.FormProvider
     com.sun.jersey.core.impl.provider.entity.StringProvider
     com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
     com.sun.jersey.core.impl.provider.entity.FileProvider
     com.sun.jersey.core.impl.provider.entity.InputStreamProvider
     com.sun.jersey.core.impl.provider.entity.DataSourceProvider
     com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
     com.sun.jersey.core.impl.provider.entity.ReaderProvider
     com.sun.jersey.core.impl.provider.entity.DocumentProvider
     com.sun.jersey.core.impl.provider.entity.StreamingOutputProviderfg
     com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
     com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
     com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
     com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General

    Nov 20, 2012 10:40:06 AM com.sun.jersey.spi.container.ContainerResponse 
    write

      SEVERE: The registered message body writers compatible with the 
      MIME media type are:
      */* ->

     com.sun.jersey.core.impl.provider.entity.FormProvider
     com.sun.jersey.core.impl.provider.entity.StringProvider
     com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
     com.sun.jersey.core.impl.provider.entity.FileProvider
     com.sun.jersey.core.impl.provider.entity.InputStreamProvider
     com.sun.jersey.core.impl.provider.entity.DataSourceProvider
     com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
     com.sun.jersey.core.impl.provider.entity.ReaderProvider
     com.sun.jersey.core.impl.provider.entity.DocumentProvider
     com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
     com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
     com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
     com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
     com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General

    SEVERE: Mapped exception to response: 500 (Internal Server Error)

    javax.ws.rs.WebApplicationException: 
    com.sun.jersey.api.MessageException:

    A message body writer for Java class
    com.myservice.domain.Person, 
    and Java type class com.myservice.domain.Person, 
    and MIME media type application/json was not found

    com.sun.jersey.api.MessageException: 

    A message body writer for Java class com.myservice.domain.Person, 
    and Java type class com.myservice.domain.Person, and MIME media type  
    application/json was not found

    HTTP Status 500 - Internal Server Error 
    The server encountered an internal error that prevented it from 
    fulfilling this request.

After scouring the Internet, I tried inserting the following proposed solution that everyone suggested into web.xml:

<init-param>
   <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
   <param-value>true</param-value>
</init-param>

But it still gives me the same issue! It does return the correct data marshalled to XML if I use APPLICATION_XML, however.

Would really appreciate it if someone could point me in the right direction.

Thank you very much for taking the time to read this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:19:14+00:00Added an answer on June 14, 2026 at 5:19 pm

    Add Genson library in your dependencies.
    It will automatically enable JSON-POJO databinding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a RESTful web service using Jersey that relies on MongoDB for persistence.
I have implemented a RESTful web service using jersey and deployed it on Tomcat,
I am using Jersey (with Jetty) and Maven to implement a RESTful service. I
I'm using Jersey to create a REST web service for a server component. The
I'm trying to debug a rest/json service that i build using Jersey and Amazon
I am using Jersey to create a web service for a server component. Unfortunately
I have a JAX-RS web service (using jersey) that accepts a JAXB object as
I am using Maven, Jersey and Jetty server to build a web service interface.
I developed a RESTful Web Service using Jersey between my mySQL server database and
I am developing a Restful Web Service using Jersey between my Android, iPhone apps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.