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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:07:50+00:00 2026-06-02T16:07:50+00:00

Here is my Request class which holds a generics request: import java.util.ArrayList; import java.util.List;

  • 0

Here is my Request class which holds a generics request:

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lorddoskias
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Request {

    private List<StringStringMapEntry> parameters = new ArrayList<StringStringMapEntry>();
    private List<StringStringMapEntry> headers = new ArrayList<StringStringMapEntry>();
    @XmlAnyElement(lax=true)
    private Object requestBody = null;  // this has to reference a JAXB-enabled object
    private String resourcePath;


    public Request() {
    }

    public Object getRequestBody() {
        return requestBody;
    }

    public void setRequestBody(Object requestBody) {
        this.requestBody = requestBody;
    }

Some parts are omitted for brevity but the essence is there. Then I have the following Sequence class:

import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lorddoskias
 */
@XmlRootElement
public class Sequence {

    private String sequenceName;
    private long numReads;
    private int sequenceLength;

    public Sequence() {
        /* Required by JAXB */
    }

    public Sequence(String name, long numReads, int length) {
        sequenceName = name;
        this.numReads = numReads;
        sequenceLength = length;
    }

    public long getNumReads() {
        return numReads;
    }

    public void setNumReads(long numReads) {
        this.numReads = numReads;
    }

    public int getSequenceLength() {
        return sequenceLength;
    }

    public void setSequenceLength(int sequenceLength) {
        this.sequenceLength = sequenceLength;
    }

    public String getSequenceName() {
        return sequenceName;
    }

    public void setSequenceName(String sequenceName) {
        this.sequenceName = sequenceName;
    }
}

And I do something like that:

List<Sequence> seq = new ArrayList<Sequence>();
        seq.add(seq1);
        seq.add(seq2);

        client.insertIndividualStatistics(PostRequest.assemblyIndividualStats(66, seq));

Here is the insertIndividualStatistics method:

public static Request assemblyIndividualStats(int stepId, List<Sequence> l) {

    Request req = new Request();
    req.setResourcePath("/stats/assembly/individual");

    req.addParameter("id", String.valueOf(stepId));
    req.setRequestBody(l);

    return req;
}

And when I try to WebResource res = client.resource(bla).path("my-path").post(req); I get :

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: javax.ws.rs.WebApplicationException: javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: class uk.org.infectogenomics.model.rest.MySequenceListWrapper nor any of its super class is known to this context.]

I thought JAXB supported simple Lists if they weren’t a root object? I even tried something different – wrapping the list in a simple JAXB annotated class:

import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lorddoskias
 */
@XmlRootElement
public class MySequenceListWrapper {

    @XmlElement(name = "List")
    private List<Sequence> list;

    public MySequenceListWrapper() {/*JAXB requires it */

    }

    public MySequenceListWrapper(List<Sequence> list) {
        this.list = list;
    }

    public List<Sequence> getList() {
        return list;
    }
}

And setting that as the requestBody but then I get a similar exception but instead of it saying that ArrayList is unrecognized it says that MySequenceListWrapper is unrecognized. I’ve read the article from Blaise Doughan blog and I suspect that at least in the latter case it should work since I have the appropriate XmlAnyElement annotation?

  • 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-02T16:07:50+00:00Added an answer on June 2, 2026 at 4:07 pm

    You could use a JAX-RS ContextResolver to make a JAXBContext that is aware of the MySequenceListWrapper class. Or you could leverage the @XmlSeeAlso annotation as follows:

    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlSeeAlso({MySequenceListWrapper.class})
    public class Request {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public abstract class Request { public class Parameters { //Threre are no members here
I designed a class which creates XML for a POST in order to call
I've got the following class which makes an HTTP post request asynchronously to avoid
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
Here's my code: if Request.Form(authorize) <> and request.form(delete) <> true then post_ids = Request.form(authorize)
Here's the code I'm using: // create a request HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
I am sending HTTP GET request and receiving data here: ssize_t numBytes = recvfrom(sock,
NOOb here. I've got a HTTP request that pulls all of the content from
The request is a simple one, but is hard to google for. Here are
From My Previous question sending request to apple - from iphone custom application Here,

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.