title: Jersey proxy client can't deserialize JSON response to RAML generated classes
body: <p>I've generated classes with <a href="https://github.com/mulesoft-labs/raml-for-jax-rs/tree/master/raml-to-jaxrs#using-the-maven-plugin" rel="nofollow noreferrer">raml-to-jaxrs maven plugin</a> (2.1.1-SNAPSHOT) from <a href="https://github.com/haba713/posti-smartship-client/blob/master/src/main/resources/root-resource-v1.raml" rel="nofollow noreferrer">this RAML file</a> and call the service with Jersey proxy client like this:</p>
  
  <pre><code>Client client = ClientBuilder.newClient();
  Logger logger = Logger.getLogger(getClass().getName());
  Feature feature = new LoggingFeature(logger, Level.INFO, null, null);
  client.register(feature);        
  client.register(new PostiSmartShipAuthenticator(username, password));
  WebTarget target = client.target(URI);
  Addresses proxy = WebResourceFactory.newResource(Addresses.class, target);
  GetAddressesAgentsResponse response = proxy.getAddressesAgents("ITELLASP", null, "51270", null, "FI", null);
  </code></pre>
  
  <p>The service responds with an array of objects:</p>
  
  <pre><code>INFO: 1 * Sending client request on thread main
  1 &gt; GET https://.../addresses/agents?type=ITELLASP&amp;zip=51270&amp;countryCode=FI
  1 &gt; Accept: application/json
  1 &gt; Authorization: Basic ...
  
  INFO: 1 * Client response received on thread main
  1 &lt; 200
  1 &lt; Connection: Keep-Alive
  1 &lt; Content-Type: application/json;charset=UTF-8
  1 &lt; Date: Sun, 15 Oct 2017 10:38:53 GMT
  1 &lt; Keep-Alive: timeout=5, max=100
  1 &lt; Server: Apache
  1 &lt; Transfer-Encoding: chunked
  [{"id":"512053201","name":"Pakettiautomaatti, S-market Kangasniemi","address1":"Otto Mannisen tie 10","address2":null,"zipcode":"51205","city":"KANGASNIEMI","state":null,"countryCode":"FI","contact":null,"phone":null,"fax":null,"email":null,"sms":null,"serviceType":null,"serviceCode":null,"openingHours":"ma-la 7.00 - 21.00, su 10.00 - 21.00"},{"id":"761053201","name":"Pakettiautomaatti, K-citymarket Pieksämäki","address1":"Kukkaroniementie 3","address2":null,"zipcode":"76105","city":"PIEKSÄMÄKI","state":null,"countryCode":"FI","contact":null,"phone":null,"fax":null,"email":null,"sms":null,"serviceType":null,"serviceCode":null,"openingHours":"ma-pe 8.00 - 21.00, la 8.00 - 20.00, su 11.00 - 18.00"},{"id":"408053201","name":"Pakettiautomaatti, S-market Vaajala","address1":"Asematie 1","address2":null,"zipcode":"40805","city":"VAAJAKOSKI","state":null,"countryCode":"FI","contact":null,"phone":null,"fax":null,"email":null,"sms":null,"serviceType":null,"serviceCode":null,"openingHours":"ma-la 7.00 - 22.00, su 10.00 - 22.00"},{"id":"409053201","name":"Pakettiautomaatti, S-market Säynätsalo","address1":"Parviaisentie 6","address2":null,"zipcode":"40905","city":"SÄYNÄTSALO","state":null,"countryCode":"FI","contact":null,"phone":null,"fax":null,"email":null,"sms":null,"serviceType":null,"serviceCode":null,"openingHours":"ma-la 7.00 - 21.00, su 10.00 - 21.00"},{"id":"405253201","name":"Pakettiautomaatti, S-market Kuokkala","address1":"Syöttäjänkatu 2","address2":null,"zipcode":"40525","city":"JYVÄSKYLÄ","state":null,"countryCode":"FI","contact":null,"phone":null,"fax":null,"email":null,"sms":null,"serviceType":null,"serviceCode":null,"openingHours":"ma-la 7.00 - 23.00, su 10.00 - 23.00"}]
  </code></pre>
  
  <p>However, the array of objects can not be deserialized to <a href="https://github.com/haba713/posti-smartship-client/blob/master/src/main/java/haba713/postismartship/resources/Addresses.java#L39" rel="nofollow noreferrer">GetAddressesAgentsResponse</a>:</p>
  
  <pre><code>Caused by: javax.json.bind.JsonbException: Can't deserialize JSON array into: class haba713.postismartship.resources.Addresses$GetAddressesAgentsResponse
  at org.eclipse.yasson.internal.serializer.DeserializerBuilder.build(DeserializerBuilder.java:129)
  at org.eclipse.yasson.internal.Unmarshaller.deserializeItem(Unmarshaller.java:56)
  at org.eclipse.yasson.internal.Unmarshaller.deserialize(Unmarshaller.java:50)
  at org.eclipse.yasson.internal.JsonBinding.deserialize(JsonBinding.java:45)
  at org.eclipse.yasson.internal.JsonBinding.fromJson(JsonBinding.java:85)
  at org.glassfish.jersey.jsonb.internal.JsonBindingProvider.readFrom(JsonBindingProvider.java:99)
  at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:257)
  at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:236)
  at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:156)
  at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1091)
  at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
  at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:834)
  at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:363)
  at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:936)
  ... 37 more
  </code></pre>
  
  <p>For some reason the plugin seems to generate always classes with <a href="https://github.com/haba713/posti-smartship-client/blob/master/src/main/java/haba713/postismartship/model/Agent.java#L6" rel="nofollow noreferrer">com.fasterxml.jackson annotations</a> even though I have </p>
  
  <pre><code>&lt;generateTypesWith&gt;
      &lt;value&gt;jaxb&lt;/value&gt;
  &lt;/generateTypesWith&gt;
  </code></pre>
  
  <p>in <a href="https://github.com/haba713/posti-smartship-client/blob/master/pom.xml" rel="nofollow noreferrer">pom.xml</a>. Probably this is not the actual issue.</p>
  
  <p>The effective dependencies currently are</p>
  
  <pre><code>javax.ws.rs:javax.ws.rs-api:2.1
  org.glassfish.jersey.core:jersey-client:2.26
  org.glassfish.jersey.core:jersey-common:2.26
  org.glassfish.jersey.ext:jersey-proxy-client:2.26
  org.glassfish.jersey.inject:jersey-hk2:2.26
  org.glassfish.jersey.media:jersey-media-jaxb:2.26
  org.glassfish.jersey.media:jersey-media-json-binding:2.26
  org.glassfish.jersey.media:jersey-media-json-jackson:2.26
  org.raml.jaxrs:jaxrs-code-generator:2.1.1-SNAPSHOT
  </code></pre>
  
  <p>Should I use some other interface than Addresses here?</p>
  
  <pre><code>Addresses proxy = WebResourceFactory.newResource(Addresses.class, target);
  </code></pre>
  
  <p>What should be changed to make deserialization to work?</p>
  
  <p>Kind regards,</p>
  
  <p>Harri</p>