users@jersey.java.net

FW: JaxB Problem

From: Jonathan Cook - FM&T <Jonathan.Cook2_at_bbc.co.uk>
Date: Wed, 18 Aug 2010 16:42:32 +0100

Sent this to the wrong list. Sorry.

> Hi,
>
> I'm using Jax-B and sending in a Json request as follows:
>
> @POST
> @Consumes("application/json")
> @Produces("application/json")
> @Path("property")
> public Response
> createOrUpdateConfiguration(ConfigurationItemList
> configItemListRequest){
> //log.debug(updateJson);
> log.debug(configItemListRequest.getModule());
> }
>
> This throws an error:
> java.lang.IllegalArgumentException: local part cannot be "null" when
> creating a QName
> at javax.xml.namespace.QName.<init>(QName.java:246)
> at javax.xml.namespace.QName.<init>(QName.java:299)
> at
> com.sun.jersey.json.impl.reader.EndElementEvent.<init>(EndElementEvent
> .java:51)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.generateEEEvent(Js
> onXmlStreamReader.java:694)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlSt
> reamReader.java:371)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlSt
> reamReader.java:166)
> at
> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.next(JsonXmlStream
> Reader.java:429)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(St
> AXStreamConnector.java:175)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(U
> nmarshallerImpl.java:333)
> at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Un
> marshallerImpl.java:312)
> at
> com.sun.jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.j
> ava:100)
>
> The json I am sending in is valid json:
> {
> "configurationItemList": [
> [
> {
> "key": "name",
> "value": "dsf"
> },
> {
> "key": "title",
> "value": "sdf"
> },
> {
> "key": "titlelink",
> "value": "sdf"
> }
> ]
> ],
> "module": "twitter",
> "sport": "winterolympics"
> }
>
> ConfigurationItemList contains a list of ConfigurationItems which
> represent the key value pairs. I'm not sure what is going wrong. I
> wondered if there was a bug in the version of jersey I am using 1.0.3?
> Or maybe the array of key value pairs needs to be structured
> differently so it has a name?
>
> If I change to just submitting a string into the POST method then it
> comes in no problem.
>
> Thanks
> Jon