users@jersey.java.net

[Jersey] Problem with getting data from a list with Jersey

From: Eric Reagan <reaganej_at_gmail.com>
Date: Fri, 10 Jun 2011 13:45:36 -0400

Hello,
     I have a class which is like
@XmlAccessorType( XmlAccessType.PUBLIC_MEMBER )
public class Airport
{
    ...

    private List<Flight> flights;

    ...
    @XmlElementWrapper(name="flightList")
    @XmlElement(name="flight})
    private List<Flight> flights;

    ...

    public List<Flight> getFlights()
    {
        return flights;
    }

    public void setFlights(List<Flight> flights)
    {
        this.flights = flights;
    }


}

    and I am getting a class has two properties of the same name about the
getFlights() method and the flights variable. The interesting problem I am
having is in my GUI code when I call getFlights() method I have the class
has two properties of the same name error. If I change my code to look like

public class Airport
{
    ...

    private List<Flight> flights;

    ...
    @XmlElementWrapper(name="flightList")
    @XmlElement(name="flight})
    private List<Flight> flights;

    ...

    public List<Flight> getFlights()
    {
        return flights;
    }

    public void setFlights(List<Flight> flights)
    {
        this.flights = flights;
    }


}


     Everything seams to work fine but the getFlights() will always return
an empty list. My flight class looks like
@XmlRootElement
public class Flight
{
    ...
}

    I don't understand what I am doing wrong when trying to my Airport
object via a Jersey GET request and either I don't get a list of flights or
I get a class has two properties of the same name exception.

Thank you,

-- 
Eric Reagan