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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:15:25+00:00 2026-06-01T15:15:25+00:00

I am using Jersey/Java to develop my REST services. I need to return an

  • 0

I am using Jersey/Java to develop my REST services. I need to return an XML representation for my CarStore :

 @XmlRootElement
public class CarStore {
 private List<Car> cars;

 public List<Car> getCars() {
  return cars;
 }
 public void setCars(List<Car> cars) {
  this.cars = cars;
 }

Here is my Car object :

@XmlRootElement
> public class Car {
 private String carName;
 private Specs carSpecs;
 private Category carCategory;
 public String getCarName() {
  return carName;
 }
 public void setCarName(String carName) {
  this.carName = carName;
 }
 public Specs getCarSpecs() {
  return carSpecs;
 }
 public void setCarSpecs(Specs carSpecs) {
  this.carSpecs = carSpecs;
 }
 public Category getCarCategory() {
  return carCategory;
 }
 public void setCarCategory(Category carCategory) {
  this.carCategory = carCategory;
 }

}

Specs and Category are enums like this :

    @XmlRootElement
> public enum Category {

 SEDANS, COMPACTS, WAGONS, HATCH_HYBRIDS, SUVS, CONVERTIBLES, COMPARABLE;
}

My resource class is :

    @GET
 @Produces({MediaType.APPLICATION_XML})
 public CarStore getCars()
 {
    return CarStoreModel.instance.getAllCars();
 }

My jersey client is :

WebResource service = client.resource(getBaseURI());
System.out.println(service.path("rest").path("cars").accept(
MediaType.APPLICATION_XML).get(String.class));

I am getting Http 204 error on access alongwith client exception :

com.sun.jersey.api.client.UniformInterfaceException

Any ideas ? Thanks !

EDIT : I have yet not developed the model class…I just initialized some car objects as dummy data and put them in carstore. Showing all the classes here would be very clumsy.
BTW, sorry for writing 204 Error..it is just that I am getting an Exception that led me think so.

  • 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-01T15:15:26+00:00Added an answer on June 1, 2026 at 3:15 pm

    I believe you are getting a UniformInterfaceException because your getCars() function is not returning an HTTP response body. The root problem is that your Car List isn’t being converted into XML by JAXB because it is missing the @XmlElement annotation.

    Your getCars() function should be:

    @GET
    @Produces(MediaType.APPLICATION_XML)
    public CarStore getCars() {
        // myCarStore is an instance of CarStore        
        return myCarStore.getCars();
    }
    

    and your Car List in CarStore should be defined:

    @XmlElement(name="car")
    private List<Car> cars;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting acquainted with implementing REST web services in Java using JAX-RS and
JSON is created in Java using Jersey's JAXB serializer. I need to deserialize it
I have written REST web service in netbean IDE using jersey framework and java.
I'm trying to create REST services using Jersey (builtin) on Glassfish. I installed GlassFish
I have a web services written in java using jersey framework when i call
All, I am using Java/Jersey 1.9 to create a web service that generates XML.
I'm trying to use Jersey to create REST services using tomcat as a container.
I have writing Java code Using Jersey library to call Rest APIs. For my
We have tried to create sample webservices helloworld in Java using Jersey and Tomcat
How to create simple webserver in Java using Eclipse, Tomcat and Jersey i.e steps

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.