users@jersey.java.net

[Jersey] Re: Marshall Exception with linked JAXB exception when sending a map with a list

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Tue, 11 Oct 2011 12:26:01 +0200

Hi,

I am afraid this is rather a question for JAXB guys (cross posting to
users_at_jaxb.java.net).
Did you try to marshal your data directly?

E.g. with something like:

             javax.xml.bind.JAXBContext jaxbCtx =
javax.xml.bind.JAXBContext.newInstance(XCollection.class, XMap.class,
Flight.class, ...);
             javax.xml.bind.Marshaller marshaller =
jaxbCtx.createMarshaller();
             
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8");
             
marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT,
Boolean.TRUE);
             marshaller.marshal(yourData, System.out);

?

Maybe you can try share at least a stack trace,
but a complete minimal test case as a maven project
would be the most helpful.

~Jakub

On 27.9.2011 15:51, reaganej_at_gmail.com wrote:
> Hello,
> I have a class like below which has a map that has a map with a
> list in it
>
> e.g. Map<String, Map<String, List<Flight>>> map ....
>
> I have followed instructions online to make a wrapper class for
> collections and maps.
>
> e.g
> @XmlRootElement
> public class XCollection
> {
> @XmlElementWrapper
> @XmlElement
> public List getList()....
> }
>
> @XmlRootElement
> public class XMap
> {
> @XmlRootElementWrapper
> @XmlELement
> public LIst<XEntry<K,V>>()...
> }
>
> I can send a list with a PUT request just fine using the above
> XCollection class. I can also send a simple Map of String, String just
> find using a PUT request and the above class.
>
> When I try and wrap my Map<String, Map<String, List<Flight>>> as a
> XMap<String, XMap<String, XCollection>>> I get the above exception.
>
> I don't understand why I am unable to create a map when I have
> registered my XCollection in my provider class and my XMap? Am I doing
> something really wrong or do I have a misunderstanding on how JAXB
> works?
>