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

  • Home
  • SEARCH
  • 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 8705367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:20:37+00:00 2026-06-13T03:20:37+00:00

I am using Jersey to create a web service for a server component. Unfortunately

  • 0

I am using Jersey to create a web service for a server component. Unfortunately I have a problem with the formatting of my JSON response, because the data is always formatted as string.

I have a simple JAXB annotated POJO with different field types:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class JaxbPojo {

    @XmlElement(name = "id_64")
    private Long id;

    @XmlElement(name = "desc")
    private String description;

    private Boolean active;

    // getters and setters
    ..
}

and a a simple resource, returning the incoming object:

@Path("/jaxb_pojo")
public class JaxbPojoResource {

    @POST
    @Consumes({ MediaType.APPLICATION_JSON })
    @Produces({ MediaType.APPLICATION_JSON })
    public JaxbPojo processBidRequest(JaxbPojo pojo) {
         return pojo;
    }

}

When sending a request to the resource with the following JSON data, the object is filled correctly inside the resource method. But the field types of the returned JSON data are always formatted as string:

me@host:/tmp $ cat simple_jaxb_pojo 
{"id_64":99,"desc":"simple JAXB POJO","active":true}

me@host:/tmp $ curl -X POST -H "Content-Type: application/json" --data-binary @simple_jaxb_pojo http://localhost/srvr/rest/jaxb_pojo
{"id_64":"99","desc":"simple JAXB POJO","active":"true"}

All used jar files (jsr311-api-1.1.1.jar, jersey-core-1.6.jar, jersey-json-1.6.jar, jersey-server-1.6.jar) are directly included in the tomcat/lib path. The JAX-RS library is used via Maven pom.xml with scope “provided”:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>jsr311-api</artifactId>
    <version>1.1.1</version>
    <scope>provided</scope>
</dependency>

My web.xml looks like this:

<servlet>
    <servlet-name>RestServlet</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.rest.RestResourcesApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

..

<servlet-mapping>
    <servlet-name>RestServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

Am I missing something or do I maybe have to configure Jackson explicitly in a way that it is using the types of my POJO. I am fairly new to this subject, so I posted every information I have on this. I hope someone can help.

  • 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-13T03:20:38+00:00Added an answer on June 13, 2026 at 3:20 am

    Interesting problem. I’m not sure exactly why this is happening but try adding:

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

    to your Jersey servlet definition in web.xml. I thought Jersey required this to produce JSON but when I removed this init-param I saw the same issue that you’re having.

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

Sidebar

Related Questions

I'm using Jersey to create a REST web service for a server component. The
I have written REST web service in netbean IDE using jersey framework and java.
I am using Maven, Jersey and Jetty server to build a web service interface.
I'm using jax-rs (jersey) to create a website / web-service that other users can
I have created a Web service using Netbeans', JEE6 and Jersey - Webservice from
All, I am using Java/Jersey 1.9 to create a web service that generates XML.
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
I follow tutorial here on how to create web service using RESTful web service
I have a REST service built using Jersey. I want to be able to
I'm building a JAX-RS web service (Jersey) and now I'm trying to start using

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.