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 7888397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:49:18+00:00 2026-06-03T05:49:18+00:00

I am using Jersey as JSR 311 implementation. The object i am trying to

  • 0

I am using Jersey as JSR 311 implementation. The object i am trying to convert to JSON looks like this:

@XmlRootElement
public class deliveryTimes{
  private Integer id;
  private Short type;
  private Integer orderId;
  /* ... more fields and autogenerated Getters & Setters ... */
}

The JSON result is:

{"deliveryTimes":
[{"type":"1","orderId":"30449",/* ... other fields ... */ },
/* ... */
]}

In words: The field “id” is getting lost. In my other objects the id-fields have other names like orderId, customerId, … and these fields don’t get lost.

My pom.xml looks like this:

<!-- other stuff -->
<!--  JERSEY -->
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.11</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-json</artifactId>
    <version>1.11</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-grizzly2</artifactId>
    <version>1.11</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-servlet</artifactId>
    <version>1.11</version>
</dependency>

<!-- Jersey + Spring -->
<dependency>
    <groupId>com.sun.jersey.contribs</groupId>
    <artifactId>jersey-spring</artifactId>
    <version>1.11</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!-- other stuff -->

There’s no further configuration.
I didn’t find anything helpful on the jersey website or via google, so I ended up here with my first post ever.

Is there any config option I am missing? How do you JSONify id-fields?

  • 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-03T05:49:19+00:00Added an answer on June 3, 2026 at 5:49 am

    There are a number of reasons why the id may not be marshalled.

    1 – It has a null value

    By default JAXB implementations will not marshal out null values. If you wish to marshal out a null value be sure to add the following annotation

    @XmlElement(nillable=true)
    

    For More Information See:

    • http://blog.bdoughan.com/2012/04/binding-to-json-xml-handling-null.html

    2 – There is a field but not no accessor (get/set) methods

    By default JAXB only maps public fields and accessors. Anything not matching this criteria is considered unmapped. You can solve this issue by specifying XmlAccessorType(XmlAccessType.FIELD)

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    public class deliveryTimes{
        ...
    }
    

    or by annotating the field

    @XmlRootElement
    public class deliveryTimes{
        @XmlElement
        private Integer id;
    }
    

    For More Information See:

    • http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html

    3 – There is a get method but no set method

    If there is a get method but no accompanying set method then your JAXB implementation will treat it as an unmapped property. To fix this you simply need to map the get method with @XmlElement.

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

Sidebar

Related Questions

I'm trying to debug a rest/json service that i build using Jersey and Amazon
I am trying to write a RESTFul Webservice using Jersey. package sample.hello.resources; @Path(/hello) public
I'm using Jersey for REST apps, i'm getting this NoClassDefException for the class AbstractRuntimeDelegate
I'm trying to implement REST API using Jersey with Spring on Tomcat but I'm
JSON is created in Java using Jersey's JAXB serializer. I need to deserialize it
I have a JAX-RS web service (using jersey) that accepts a JAXB object as
I'm using Jersey 1.11 and trying to model both POST and DELETE methods in
I'm using Jersey to build a REST API to a service. I'd like to
I have a REST service that produces a JSON output. I'm using Jersey. I
I am using Jersey 1.4, the ApacheHttpClient , and the Apache MultiThreadedHttpConnectionManager class to

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.