users@wadl.java.net

START_ARRAY Exception

From: Roman MANZ <RManz_at_amadeus.com>
Date: Fri, 4 Sep 2015 06:51:22 +0000

Dear WADL users,

I am a newbie to WADL and Java Web Services in general and would like to ask for your help.
I have a server (no Java stack) and try to create a WADL to create Java client code to support Java clients.
Examples when the server returns a simple JSON object work well, no problem.
If the server returns an array of objects the wadl2java code generation works well but when I run the client it produces this exception:
Exception in thread "main" javax.ws.rs.ProcessingException: Error reading entity from input stream.
                at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:867)
                at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:786)
                at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
                at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:115)
                at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
                at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
                at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
                at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:419)
                at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:267)
                at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:112)
                at net.test.simple.Localhost_Api$Items.getAsItemList(Localhost_Api.java:128)
                at net.test.simple.main.main(main.java:18)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of net.test.simple.ItemList out of START_ARRAY token
at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInpu; line: 1, column: 1]
                at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
                at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:854)
                at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:850)
                at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1258)
                at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:155)
                at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:134)
                at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1413)
                at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:867)
                at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:811)
                at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:256)
                at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:235)
                at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
                at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
                at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:852)
                ... 11 more

I am attaching the WADL and XSD files.
This is the command I use to create the code:
$ wadl2java -s jaxrs20 -o src20 -p net.test.simple simple-wadl.xml
The server returns this JSON structure:
$ curl -o - http://localhost:12006/api/items
[{"_id":"55e6aa8758224500c988d2aa","name":"Adam","spouse":"Eve"}]
I use Jersey2.21 in my Eclipse project; the full list of jar's I use is:
hk2-api-2.4.0-b31.jar
hk2-locator-2.4.0-b31.jar
hk2-utils-2.4.0-b31.jar
jackson-annotations-2.6.1.jar
jackson-core-2.6.1.jar
jackson-databind-2.6.0-rc4.jar
jackson-jaxrs-base-2.6.1.jar
jackson-jaxrs-json-provider-2.6.1.jar
jackson-module-jaxb-annotations-2.6.1.jar
JavaSE-1.7
javax.annotation-api-1.2.jar
javax-inject.jar
javax.ws.rs-api-2.0.jar
jax-rs-ri-2.0-m13-3.jar
jersey-client-2.21.jar
jersey-common-2.21.jar
jersey-entity-filtering-2.21.jar
jersey-guava-2.6.jar
jersey-media-json-jackson-2.21.jar

I have asked Google many times with different search patterns. The problem seems to be happening also to other people. The difference is that all solutions I've found are based on 'manual' code which looks quite different to the generated code I work with. And since I am new to this topic I cannot really compare these situations with mine.

Any help would be appreciated.
Many thanks & best regards
Roman
IMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system . Amadeus Data Processing GmbH Gesch?ftsf?hrer: Dr. Wolfgang Krips Sitz der Gesellschaft: Erding HR M?nchen 48 199 Berghamer Strasse 6 85435 Erding Germany