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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:46:25+00:00 2026-06-15T03:46:25+00:00

The JSON is: {list: [1,2,3,4,5,6,7,8,9,10]} Here’s how I implement the JAXB bean: package com.anon.sortweb.jaxb;

  • 0

The JSON is:

{"list": [1,2,3,4,5,6,7,8,9,10]}

Here’s how I implement the JAXB bean:

package com.anon.sortweb.jaxb;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;

@XmlRootElement
public class JsonBean {
    @XmlElement(name="list")
    private int[] list;

    public JsonBean() {}

    public void setList(int[] list) {
        this.list = list;
    }

    public int[] getList() {
        return list;
    }
}

My web application works fine (I’m able to successfully access other resources) but this one resource (that I pass my JSON to) returns a 415 Media Type Unsupported exception.

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces("text/html")
public String sortAndReturnHtml(JsonBean listBean) { ... }

How do I correctly write my JAXB bean to encapsulate a list of integers?

Thanks in advance!

  • 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-15T03:46:26+00:00Added an answer on June 15, 2026 at 3:46 am

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

    Your JAXB bean is a perfectly reasonable representation of your JSON data. The JAXB (JSR-222) spec does not cover JSON binding so the answer ultimately comes down to how/if your JAX-RS implementation interprets JAXB metadata to produce/consume JSON.

    Demo

    Below is how it would work with MOXy.

    package forum13648734;
    
    import java.util.*;
    import javax.xml.bind.*;
    import javax.xml.transform.stream.StreamSource;
    import org.eclipse.persistence.jaxb.JAXBContextProperties;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            Map<String, Object> properties = new HashMap<String, Object>(2);
            properties.put(JAXBContextProperties.MEDIA_TYPE, "application/json");
            properties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, false);
            JAXBContext jc = JAXBContext.newInstance(new Class[] {JsonBean.class}, properties);
    
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            StreamSource json = new StreamSource("src/forum13648734/input.json");
            JsonBean jsonBean = unmarshaller.unmarshal(json, JsonBean.class).getValue();
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.marshal(jsonBean, System.out);
        }
    
    }
    

    input.json/Output

    {"list":[1,2,3,4,5,6,7,8,9,10]}
    

    For More Information

    • http://blog.bdoughan.com/2011/08/json-binding-with-eclipselink-moxy.html
    • http://blog.bdoughan.com/2012/05/moxy-as-your-jax-rs-json-provider.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues populating a dropdown list with a JSON List. Here is
I have a json structure that looks something like this: list:[ { type:link, href:http://google.com
Here is my Sencha Touch 2 code which shows the JSON list data in
Note: I also posted this question on the AngularJS mailing list here: https://groups.google.com/forum/#!topic/angular/UC8_pZsdn2U Hi
While updating a big json list, I'm getting the following error : 2012-04-01T09:34:00+00:00 app[run.1]:
I need to update a json list of object via url post data. For
I am trying to encode a list as JSON, compress it using gzip in
I'd like know how do to a method return a JSON array of List,
I'm using asp.net mvc2 and trying to send a list of json objects with
I'm having a problem. I have the list of JSON objects in a separate

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.