title: Spring Boot - Jersey Client - Jackson Cannot construct instance of `java.time.Instant`
body: <p>Using Jersey Client 2.28 I am trying to receive a DTO containing the following data:</p>
  <pre><code>{
      &quot;entityId&quot;: &quot;0de46a94-bc95-437f-9eca-dcfd60f7aed3&quot;,
      &quot;productId&quot;: &quot;9c328c45-deba-4b84-8fb4-0d2aea885fc0&quot;,
      &quot;status&quot;: &quot;ACTIVE&quot;,
      &quot;startDatetime&quot;: &quot;2020-05-12T08:54:23Z&quot;,
      &quot;endDatetime&quot;: null,
  }
  </code></pre>
  <p>When receiving it, I get the following error:</p>
  <pre><code>com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `java.time.Instant` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2020-05-12T08:54:23Z')
   at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 190] (through reference chain: com.fundraiser.dto.OfferDto[&quot;startDatetime&quot;])
  </code></pre>
  <p>I know I should be able to retrieve this back without a ton of custom serializers or adapters. Upon googling it appears there's been other close issues to this, but none of them resolve my issue:</p>
  <p><a href="https://stackoverflow.com/questions/27952472/serialize-deserialize-java-8-java-time-with-jackson-json-mapper">serialize/deserialize java 8 java.time with Jackson JSON mapper</a></p>
  <p><a href="https://stackoverflow.com/questions/45863678/json-parse-error-can-not-construct-instance-of-java-time-localdate-no-string-a">JSON parse error: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value</a></p>
  <p>I've tried adding combinations of these maven imports to get this to work, but nothing:</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-datatype-jdk8&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &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;
  </code></pre>
  <p>If I add the following jersey media moxy, I do get my object back, but any dates are marshalled as null:</p>
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
    &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
    &lt;version&gt;2.28&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>I am using Spring Boot 2.2.0 and my pom.xml looks like the following:</p>
  <pre><code>&lt;project xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
           xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.2.0.RELEASE&lt;/version&gt;
    &lt;/parent&gt;
  
    &lt;groupId&gt;com.test&lt;/groupId&gt;
    &lt;artifactId&gt;test-webapp&lt;/artifactId&gt;
    &lt;version&gt;1.0.0&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;name&gt;test-webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
        &lt;artifactId&gt;lombok&lt;/artifactId&gt;
        &lt;version&gt;1.18.8&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
        &lt;version&gt;2.28&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt;
        &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt;
        &lt;version&gt;2.28&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.test&lt;/groupId&gt;
        &lt;artifactId&gt;test-client&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
        &lt;version&gt;2.3.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;version&gt;2.3.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
        &lt;version&gt;2.3.0.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  
    &lt;properties&gt;
      &lt;java.version&gt;11&lt;/java.version&gt;
    &lt;/properties&gt;
  
    &lt;build&gt;
      &lt;finalName&gt;test-webapp&lt;/finalName&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;source&gt;11&lt;/source&gt;
            &lt;target&gt;11&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;goals&gt;
                &lt;goal&gt;repackage&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
      &lt;defaultGoal&gt;install&lt;/defaultGoal&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  
  </code></pre>
  <p>Is there something I'm blatantly missing? I just feel like this shouldn't be as big of a problem as it has been.</p>
  <p>Code used to retrieve data:</p>
  <pre><code>
   public TestClient() {
          this.client = ClientBuilder.newBuilder().register(&quot;application/json, */*&quot;).build();
      }
  
      private WebTarget webTarget() {
          return client
                  .target(baseUri)
                  .path(&quot;api&quot;)
                  .path(&quot;v1&quot;);
      }
  
      private WebTarget entityTarget() {
          return webTarget()
                  .path(&quot;entity&quot;);
      }
  
      public DataDto getEntityById(@NonNull UUID entityId) {
  // Error occurs here
          return entityTarget()
                  .path(entityId.toString())
                  .request(MediaType.APPLICATION_JSON)
                  .get(DataDto.class);
      }
  
  </code></pre>
  <p>UPDATE: Added Dto class:</p>
  <pre><code>package com.test.dto;
  
  import lombok.Data;
  import lombok.experimental.Accessors;
  
  import java.time.Instant;
  import java.time.LocalDateTime;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.UUID;
  
  @Data
  @Accessors(chain = true)
  public class DataDto {
      private UUID entityId;
      private UUID productId;
      private String status;
      private Instant startDatetime;
      private Instant endDatetime;
  }
  </code></pre>