users@jersey.java.net

Re: [Jersey] java.io.IOException: Error marshalling JAXB object of type "class com.mycompany.js.MyBean".

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 06 Aug 2009 10:33:57 +0200

Hi,

I do not think the Java type you are using is supported by JAXB i.e.
it does not know, by default, how to convert an instance of
Map<String, List<String>> to/from XML.

You may need to utilize an XmlTypeAdapter. I recommend searching the
JAXB users archive:

   http://www.nabble.com/java.net---jaxb-users-f13500.html

and posting a question to that list.

Paul.

On Aug 5, 2009, at 10:21 PM, RajKal wrote:

> Hello Gurus,
>
> Need help in resolving the below issue. Running on Weblogic 10.0
> with Java 1.5 version.
> Able to get proper response for simple Map and list but when i am
> using complex Map getting below error.
>
> This is part of MyBean class.
>
> public Map<String, List<String>> getValueMapList() {
> return valueMapList;
> }
>
> public void setValueMapList(Map<String, List<String>>
> valueMapList) {
> this.valueMapList = valueMapList;
> }
>
>
>
> java.io.IOException: Error marshalling JAXB object of type "class
> com.mycompany.js.MyBean".
> at
> com
> .sun
> .jersey
> .core
> .provider
> .jaxb
> .AbstractRootElementProvider
> .writeTo(AbstractRootElementProvider.java:145)
> at
> com
> .sun
> .jersey.spi.container.ContainerResponse.write(ContainerResponse.java:
> 254)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:578)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:502)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:493)
> Truncated. see log file for complete stacktrace
> com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of
> IllegalAnnotationExceptions
> java.util.List is an interface, and JAXB can't handle interfaces.
> this problem is related to the following location:
> at java.util.List
> at public java.util.Map
> com.mycompany.js.MyBean.getValueMapList()
> at com.mycompany.js.MyBean
> java.util.List does not have a no-arg default constructor.
> this problem is related to the following location:
> at java.util.List
> at public java.util.Map
> com.mycompany.js.MyBean.getValueMapList()
> at com.mycompany.js.MyBean
>
> at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException
> $Builder.check(IllegalAnnotationsException.java:102)
> at
> com
> .sun
> .xml
> .bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:
> 447)
> at
> com
> .sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:
> 288)
> at com.sun.xml.bind.v2.runtime.JAXBContextImpl
> $JAXBContextBuilder.build(JAXBContextImpl.java:1111)
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
> 154)
> Truncated. see log file for complete stacktrace
> >
>
> Thanks,
> Raj
>