users@jaxb.java.net

Re: JSON unmarshaling problem

From: Christopher Schmidt <fakod666_at_googlemail.com>
Date: Sat, 11 Dec 2010 17:42:44 +0100

Thanks Pavel for your answer. I will try to create a testcase for Java (will
take some days), and I think that the exception is thrown in the Jersey
part, isn't it? So I will post this to the Jersey list as well.

Back soon Christopher

On Sat, Dec 11, 2010 at 12:59 PM, Pavel Bucek <pavel.bucek_at_oracle.com>wrote:

> Do you have reproducible testcase? I can create my own but it might be
> faster to get what you have.. (and in this case - I'm not very familiar with
> scala, so it might take even more time ..)
>
> .. you can send it to me privately if it contains some sensitive info.
>
> Thanks,
> Pavel
>
>
> On 12/11/10 9:58 AM, Christopher Schmidt wrote:
>
>> My mail got lost, so I try to send it again...
>>
>>
>> Hi Pavel, I am using Jersey 1.4 that uses JAXB 2.1.12 AFAIK (I am using
>> maven).
>>
>> Christopher
>>
>> On Thu, Dec 9, 2010 at 10:08 AM, Christopher Schmidt
>> <fakod666_at_googlemail.com> wrote:
>>
>> Hi all, I want to create Xml root elements for the following JSON
>> structure:[ { "start" : "http://localhost:7474/db/data/node/3",
>>
>> "nodes" : [ "http://localhost:7474/db/data/node/3",
>> "http://localhost:7474/db/data/node/1" ],
>>
>> }, { "start" : "http://localhost:7474/db/data/node/3", "nodes" : [
>> "http://localhost:7474/db/data/node/3",
>> "http://localhost:7474/db/data/node/2" ],
>>
>> } ]
>> I am using a REST interface, Jersey as REST client library and Scala.
>> If I use Scala objects like these:
>> @XmlAccessorType(XmlAccessType.FIELD)@XmlRootElement
>>
>> class GetPath { var array:java.util.List[TraversePath] = _}
>> @XmlAccessorType(XmlAccessType.FIELD)@XmlRootElementclass TraversePath
>> { var start:String = _
>>
>> var nodes . . .}
>> I get the following error:
>> java.lang.ArrayIndexOutOfBoundsException: -1 at
>> java.util.ArrayList.get(ArrayList.java:324)
>>
>> at
>> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.valueRead(JsonXmlStreamReader.java:162)
>> at
>>
>> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:327)
>>
>> at
>> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.readNext(JsonXmlStreamReader.java:175)
>> at
>>
>> com.sun.jersey.json.impl.reader.JsonXmlStreamReader.next(JsonXmlStreamReader.java:445)
>>
>> at
>> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)
>> at
>>
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
>>
>> at
>> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
>> at
>>
>> com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalJAXBElementFromJSON(BaseJSONUnmarshaller.java:103)
>>
>> at
>> com.sun.jersey.json.impl.BaseJSONUnmarshaller.unmarshalFromJSON(BaseJSONUnmarshaller.java:92)
>> at
>>
>> com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider.readFrom(JSONRootElementProvider.java:100)
>>
>> at
>> com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:106)
>> at
>>
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:549)
>>
>> at
>> com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:502)
>> at
>> com.sun.jersey.api.client.WebResource.handle(WebResource.java:560)
>>
>>
>> Any advice?
>>
>
>


-- 
Christopher
twitter: @fakod
blog: http://blog.fakod.eu