title: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "errorMessages" (Class ReasonDTO), not marked as ignorable
body: <p>I am trying to parse the returned JSON from a REST service call back into the DTO object so it can be used on the client side.  The client code looks like:</p>
  
  <pre><code>@Test
  public void retrieveAllReasonsUsingJSONandGet() throws Exception {
      List&lt;Object&gt; providers = new ArrayList&lt;Object&gt;();
      providers.add(new org.codehaus.jackson.jaxrs.JacksonJsonProvider());
  
      WebClient client = WebClient.create(endpointUrl + "/retrieveall", providers);
  
      Response r = client.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).get();
      assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
  
      MappingJsonFactory factory = new MappingJsonFactory();
      JsonParser parser = factory.createJsonParser((InputStream)r.getEntity());
      TypeReference&lt;List&lt;ReasonDTO&gt;&gt; ref = new TypeReference&lt;List&lt;ReasonDTO&gt;&gt;() {} ;
      List&lt;ReasonDTO&gt; allReasons = (List&lt;ReasonDTO&gt;) parser.readValueAs(ref);
  
      assertEquals(43, allReasons.size());
  } // retrieveAllReasonsUsingJSONandGet
  </code></pre>
  
  <p>One stanza of the returned JSON (there are 43 of them) looks like:</p>
  
  <pre><code>{
      "reasonCode": "...",
      "reason": "...",
      "hasError": false,
      "errorMessages": [],
      "hasWarning": false,
      "warningMessages": []
  },
  </code></pre>
  
  <p>The DTO object look like (ignore the XML stuff since the same DTOs are passed back using JAX-WS so they need to be marshalled/unmarshalled as XML too):</p>
  
  <pre><code>public class ReasonDTO {
      private String reasonCode;
      private String reason;
      private boolean hasError = false;
      @XmlElementWrapper(name = "errorMessages")
      @XmlElement(name = "errorMessage")
      private List&lt;String&gt; errorMessages = new ArrayList&lt;String&gt;();
      private boolean hasWarning = false;
      @XmlElementWrapper(name = "warningMessages")
      @XmlElement(name = "warningMessage")
      private List&lt;String&gt; warningMessages = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>The full exception that is getting thrown is:</p>
  
  <pre><code>org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "errorMessages" (Class ReasonDTO), not marked as ignorable
   at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@29b429b4; line: 1, column: 91] (through reference chain: ReasonDTO["errorMessages"])
      at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
      at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:248)
      at org.codehaus.jackson.map.deser.StdDeserializer.reportUnknownProperty(StdDeserializer.java:542)
      at org.codehaus.jackson.map.deser.StdDeserializer.handleUnknownProperty(StdDeserializer.java:528)
      at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:671)
      at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:519)
      at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:350)
      at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:116)
      at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:93)
      at org.codehaus.jackson.map.deser.CollectionDeserializer.deserialize(CollectionDeserializer.java:25)
      at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:1961)
      at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:852)
      at org.codehaus.jackson.JsonParser.readValueAs(JsonParser.java:1118)
      at TE_ReasonREST_ServiceTester.retrieveAllReasonsUsingJSONandPost(TE_ReasonREST_ServiceTester.java:73)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:600)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>The error message seems to be saying that the "errorMessages" field isn't found in the DTO, but mine is there.  The other posts I have read about this suggest to use</p>
  
  <pre><code>@JsonIgnoreProperties
  </code></pre>
  
  <p>but I don't want to ignore the errorMessage since if there are some present, they indicate problems.</p>
  
  <p>Any thoughts as to what my problem might be and where I should look for solutions?</p>
  
  <p>Thanks a lot.</p>