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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:08:11+00:00 2026-05-27T14:08:11+00:00

I am using jersey, and I want to send (in a POST) a list

  • 0

I am using jersey, and I want to send (in a POST) a list of objects to the server. This is the scenario:

@XmlRootElement
class Myclass{
    //some primitive attributes + empty constructor + getter/setters
}

MyClass is both on server and client side.

@XmlRootElement
class MyClasses{
   private List<MyClass> classes = new ArrayList<MyClass>();
   // put some MyClass into the list
}

class Sender{
   MyClasses list = new MyClasses();
   // after client initialization i want to send this list in a POST to server
   WebResource service = client.resource(baseURI());

   //I tried
   service.type("application/xml").accept("application/xml").post(ClientResponse.class,list);
}   

//on server side
@path(“/tosend”)

class receiver{

    public Response posted(JAXBElement<MyClasses> vals){
           //work with vals.getValue() as the list of all Objects
    }
} 

Unfortunately, I have this error :
ContainerRequest getEntity : A Message body reader for JAXBElement and JAXBElement
and MIME Type application/octet-stream was not found.

How can I fix that?

  • 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-05-27T14:08:11+00:00Added an answer on May 27, 2026 at 2:08 pm

    Are you sure your code looks exactly as written above? The exception suggests you are not setting the content type of the request. Don’t use JAXBElement, and make sure the content type of the request is set to application/xml. In your code snippet you seem to be doing it. But the exception says the media type is application/octet-stream. So either the code snippet does not match your real code or the exception is coming from a different section of the code or you have some filters that change the message headers before it reaches the posted() method. Annotate the method with @Consumes(MediaType.APPLICATION_XML).

    Btw, you don’t need to use the MyClasses wrapper class. You can simply send List and it will work as well.

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

Sidebar

Related Questions

How do I send GET requests using the Jersey Client API to a server
I have a REST service built using Jersey. I want to be able to
I'm using Jersey to create a REST web service for a server component. The
I am using Jersey JAX-RS. I want to return a Response with a Map
I am using Jersey/Tomcat6 for dveloping some web services. Compared to what I did
I'm using Jersey 1.11 and trying to model both POST and DELETE methods in
Can you pass some data from a javax.servlet.Filter to a Jersey endpoint without using
I see some are using Jersey w/ Spring. With Spring 3.0 there are now
I'm building an API using Jersey on the Glassfish 3.1 server and need to
I'm writing a mule application that implements some web services using Jersey. I'd like

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.