users@jersey.java.net

Re: [Jersey] FW: JaxB Problem

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 19 Aug 2010 10:09:22 +0200

Hi,

I definitely think it is a bug too, probably an error reporting issue
because there is mismatch between the JSON and the object model.

Cannot confirm until i try it. How are you generating the JSON?
Perhaps you can marhsall out an instance of ConfigurationItemList to
compare?

In the JSON example, as Chris points you have an array in array which
would be a bit like having List<List<ConfigurationItem>>.

The following in the 1.0.3 user guide may help:

https://jersey.dev.java.net/nonav/documentation/1.0.3/user-
guide.html#json

take note the the example which is similar to your structure.

Paul.



On Aug 18, 2010, at 7:09 PM, Tatu Saloranta wrote:

> It does sound like sort of a bug. Underlying secondary issue is that
> there are different implementations of QName; some of which accept
> nulls (as equivalent to ""), others that do not. I forget which kinds
> came from which sources; I think some containers (WebSphere) had
> non-standard variant.
> I mention this only because it may be tricky to reproduce the issue on
> some containers; and that it probably does not affect all users.
>
> But since passing of empty String should always work, it sounds like
> code in json-to-stax converter should just convert nulls to empty
> Strings.
>
> -+ Tatu +-
>
> On Wed, Aug 18, 2010 at 8:42 AM, Jonathan Cook - FM&T
> <Jonathan.Cook2_at_bbc.co.uk> wrote:
>> 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(JsonXmlStreamReader.java:694)
>> at
>> com
>> .sun
>> .jersey
>> .json
>> .impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:
>> 371)
>> at
>> com
>> .sun
>> .jersey
>> .json
>> .impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:
>> 166)
>> at
>> com
>> .sun
>> .jersey
>> .json.impl.reader.JsonXmlStreamReader.next(JsonXmlStreamReader.java:
>> 429)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:
>> 175)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:333)
>> at
>> com
>> .sun
>> .xml
>> .bind
>> .v2
>> .runtime
>> .unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:312)
>> at
>> com
>> .sun
>> .jersey.json.impl.JSONUnmarshaller.unmarshal(JSONUnmarshaller.java:
>> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>