title: Cannot construct instance of `java.time.LocalDate` - Spring boot, elasticseach, jackson
body: <p>I'm using <code>Spring-boot 2.0.0.M7</code> and <code>spring-boot-starter-data-elasticsearch</code> and <code>elasticsearch 5</code> and I'm getting an error by deserializing a <code>LocalDate</code> field. </p>
  
  <p>My Document looks like that:</p>
  
  <pre><code>@Document(indexName= "myIndex", type = "cluster")
  public class Cluster {
  
      @Id
      @Field
      private Long id;
      @Field
      private String name;
      @Field
      private ClusterUrl clusterUrl;
      @Field
      private ClusterVisible clusterVisible;
  }
  </code></pre>
  
  <p>Where ClusterVisible is a child object which holds the <code>LocalDates</code>:</p>
  
  <pre><code>public class ClusterVisible {
  
      @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy")
      private LocalDate start;
      @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd.MM.yyyy")
      private LocalDate end;
  }
  </code></pre>
  
  <p>So I just make a query for one cluster Id and I get this exception:</p>
  
  <pre><code>com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.LocalDate` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
   at [Source: (String)"{"id":12345,"name":"Cluster name ","clusterName":{"de":"Cluster de","it":null,"fr":null},"clusterUrl":{"de":"/url/results","it":null,"fr":null},"clusterVisible":{"start":{"year":2017,"month":"OCTOBER","dayOfMonth":9,"dayOfWeek":"MONDAY","era":"CE","dayOfYear":282,"leapYear":false,"mo"[truncated 252 chars]; line: 1, column: 388] (through reference chain: com.example.elasticsearch5.es.cluster.model.Cluster["clusterVisible"]-&gt;com.example.elasticsearch5.es.cluster.model.ClusterVisible["start"])
      at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
      at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1451)
      at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1027)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1290)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:326)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159)
      at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
      at org.springframework.data.elasticsearch.core.DefaultEntityMapper.mapToObject(DefaultEntityMapper.java:65)
  </code></pre>
  
  <p>I already know that I need to add some jackson dependencies for the <code>java.time api</code> so I added:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
      &lt;version&gt;2.9.4&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>But this does not help for now. I also checked the entry in the index by making a query using kibana. The result of the query is:</p>
  
  <pre><code>...
  "clusterVisible": {
      "start": {
        "year": 2017,
        "month": "OCTOBER",
        "dayOfMonth": 25,
        "dayOfWeek": "WEDNESDAY",
        "era": "CE",
        "dayOfYear": 298,
        "leapYear": false,
        "monthValue": 10,
        "chronology": {
          "id": "ISO",
          "calendarType": "iso8601"
        }
      },
      "end": {
        "year": 3000,
        "month": "JANUARY",
        "dayOfMonth": 1,
        "dayOfWeek": "WEDNESDAY",
        "era": "CE",
        "dayOfYear": 1,
        "leapYear": false,
        "monthValue": 1,
        "chronology": {
          "id": "ISO",
          "calendarType": "iso8601"
        }
      }
  }
  </code></pre>
  
  <p>What do I miss for fixing this error? </p>
  
  <p>Addition: The exact error occours at <code>mapper.mapToObject</code>. So I created a <code>new DefaultEntityMapper();</code> some lines before. Could that be the issue?</p>
  
  <pre><code>@Override
  public Page&lt;Cluster&gt; findClustersAndScoreByText(String text) {
      QueryBuilder queryBuilder = QueryBuilders.boolQuery()
              .should(QueryBuilders.queryStringQuery(text).lenient(true).defaultOperator(Operator.OR)
                      .field("name")
                      .field("svno"));
  
      NativeSearchQuery nativeSearchQuery = new NativeSearchQueryBuilder().withQuery(queryBuilder)
              .withPageable(PageRequest.of(0, 100)).build();
  
      DefaultEntityMapper mapper = new DefaultEntityMapper();
      ResultsExtractor&lt;Page&lt;Cluster&gt;&gt; rs = new ResultsExtractor&lt;Page&lt;Cluster&gt;&gt;() {
  
          @Override
          public Page&lt;Cluster&gt; extract(SearchResponse response) {
              ArrayList&lt;Cluster&gt; hotels = new ArrayList&lt;&gt;();
              SearchHit[] hits = response.getHits().getHits();
              for (SearchHit hit : hits) {
                  try {
                      Cluster cluster = mapper.mapToObject(hit.getSourceAsString(), Cluster.class);
                      cluster.setScore(hit.getScore());
                      hotels.add(cluster);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return new PageImpl&lt;&gt;(hotels, PageRequest.of(0, 100), response.getHits().getTotalHits());
          }
      };
  
      return elasticsearchTemplate.query(nativeSearchQuery, rs);
  }
  </code></pre>