dev@jersey.java.net

Re: Issue with json support in 0.6 release

From: Peter Liu <Peter.Liu_at_Sun.COM>
Date: Fri, 07 Mar 2008 10:54:01 -0800

Thanks. I'll give this a try.

Peter

Paul Sandoz wrote:
> Jakub Podlesak wrote:
>> Hi Peter,
>>
>> attributes serialization is missing at the moment. It is imho to late
>> (in the snapshot release cycle) to add it now.
>>
>
> Drat...
>
> Peter, as Jakub shows the work around is to generate a
> ContextResolver<JAXBContext> with the list of JAXB beans you have
> generated. Or instead you can check for the package name of the JAXB
> bean, that way you don't need to include all the beans.
>
> Paul.
>
>
>> You can however easily switch to the 0.5 behaviour
>> be using your custom JAXBContext via providing following context
>> resolver
>> in your application:
>>
>> @Provider
>> public final class JAXBContextResolver implements
>> ContextResolver<JAXBContext> {
>> private final JAXBContext context;
>> private final Set<Class> types;
>> private final Class[] cTypes = {<put your jaxb beans classes
>> here>};
>> public JAXBContextResolver() throws Exception {
>> Map<String, Object> props = new HashMap<String, Object>();
>> props.put(JSONJAXBContext.JSON_NOTATION, "BADGERFISH");
>> this.types = new HashSet(Arrays.asList(cTypes));
>> this.context = new JSONJAXBContext(cTypes, props);
>> }
>> public JAXBContext getContext(Class<?> objectType) {
>> return (types.contains(objectType)) ? context : null;
>> }
>> }
>>
>> Hope it helps.
>>
>> ~Jakub
>>
>> On Thu, Mar 06, 2008 at 04:02:48PM -0800, Peter Liu wrote:
>>> I am trying out the 0.6 release and I am getting the following
>>> exception when returning a jaxb object
>>> with the mime type set to application/json:
>>>
>>> java.lang.UnsupportedOperationException: Not supported yet.
>>> at
>>> com.sun.ws.rest.impl.json.writer.JsonXmlStreamWriter.writeAttribute(JsonXmlStreamWriter.java:288)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.output.XMLStreamWriterOutput.attribute(XMLStreamWriterOutput.java:131)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl.attribute(XmlOutputAbstractImpl.java:106)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.XMLSerializer.attribute(XMLSerializer.java:442)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.property.AttributeProperty.serializeAttributes(AttributeProperty.java:99)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeAttributes(ClassBeanInfoImpl.java:331)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:587)
>>>
>>> at
>>> com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:312)
>>>
>>>
>>>
>>> The was working in 0.5 release.
>>>
>>> Thanks.
>>>
>>> Peter
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>
>