dev@jersey.java.net

JaxB Problem

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

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.j
ava:51)
        at
com.sun.jersey.json.impl.reader.JsonXmlStreamReader.generateEEEvent(Json
XmlStreamReader.java:694)
        at
com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStre
amReader.java:371)
        at
com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStre
amReader.java:166)
        at
com.sun.jersey.json.impl.reader.JsonXmlStreamReader.next(JsonXmlStreamRe
ader.java:429)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
StreamConnector.java:175)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
arshallerImpl.java:333)
        at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
rshallerImpl.java:312)
        at
com.sun.jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.jav
a: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