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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:58:05+00:00 2026-06-11T10:58:05+00:00

Our Application has a Class that wraps Jersey REST functionality. One Method is public

  • 0

Our Application has a Class that wraps Jersey REST functionality. One Method is public <T extends Storable> List<T> retrieve(Class<T[]> pCls) throws StorageException, that is called like retrieve(Item[].class) to get the whole List of Items from the resource /items (see below).

The answer from the server is [{"price":1.0,"specialPrice":0.0,"name":"Beverage","special":false,"category":"BEVERAGE","cost":0.0,"available":false,"id":0},{"price":2.0,"specialPrice":0.0,"name":"Meal","special":false,"category":"DISH","cost":0.0,"available":false,"id":0}], which is what I expect.

But the Application exits with Exception in thread "main" javax.ws.rs.WebApplicationException: javax.xml.bind.UnmarshalException, with linked exception [com.sun.istack.internal.SAXParseException2; lineNumber: 1; columnNumber: 14; unexpected element (uri:"", local:"price"). Expected elements are <{}article>,<{}item>].

Code for retrieve (client):

ClientResponse cr = this.resource.path(resourcePath)
                .accept(MediaType.APPLICATION_JSON_TYPE)
                .get(ClientResponse.class);

        T[] a = cr.getEntity(pCls);

Code for the resource (on the server):

@Path("/items")
public class ItemListResource {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public Response getItemList() {
        LinkedList<Item> l = new LinkedList<Item>();
        l.add(new Item(1.0, "Beverage", Category.BEVERAGE));
        l.add(new Item(2.0, "Meal", Category.DISH));
        return Response.ok(l).build();
    }
}

Code for Item:

@XmlRootElement
public class Item extends Article {
    private Category category;
    private double cost;
    private boolean available;
};
  • 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-11T10:58:07+00:00Added an answer on June 11, 2026 at 10:58 am

    I solved the Problem by using Jackson like in this answer: https://stackoverflow.com/a/9725228/1116842

    ClientConfig cfg = new DefaultClientConfig();
    cfg.getClasses().add(JacksonJsonProvider.class);
    Client client = Client.create(cfg);
    

    Matt Ball says:

    Jackson’s MessageBodyReader implementation appears to be more well-behaved than the Jersey JSON one.

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

Sidebar

Related Questions

Our application has many controls that are created dynamically. For example, a navigation pane
Our application has a couple of shell scripts that are called from web-based Oracle
I'm currently going through the process of running FxCop through our application that has
My company has a ClickOnce application that has been in use with our customers
Our main application has both a asp.net and winforms component. There is a class
Our application has a service layer and a DAO layer, written as Spring beans.
Our Java application has a number of modules which implement a common interface. By
I have a Windows application. The windows application has our XML Library on it.
In our application through the process of developing a lot of JAR files has
Our large application (VB.Net, Framework 3.5) has been developed more or less from the

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.