XML : LocalDate serialization. Confused about org.glassfish.jersey.media and com.fasterxml.jackson

:) All the posts suggest that I should use JavaTimeModule to parse LocalDate. With this dependency:

  <dependency>  <groupId>com.fasterxml.jackson.datatype</groupId>  <artifactId>jackson-datatype-jsr310</artifactId>  <version>2.4.0</version>  </dependency>    

However, when I add the previous dependency to my pom.xml I get request failed 500. Here is my pom.xml

  <dependencyManagement>      <dependencies>          <dependency>              <groupId>org.glassfish.jersey</groupId>              <artifactId>jersey-bom</artifactId>              <version>${jersey.version}</version>              <type>pom</type>              <scope>import</scope>          </dependency>      </dependencies>  </dependencyManagement>    <dependencies>      <dependency>          <groupId>db</groupId>          <artifactId>db</artifactId>          <version>1</version>      </dependency>      <dependency>          <groupId>org.glassfish.jersey.media</groupId>          <artifactId>jersey-media-json-jackson</artifactId>      </dependency>      <dependency>          <groupId>org.glassfish.jersey.containers</groupId>          <artifactId>jersey-container-grizzly2-http</artifactId>      </dependency>    

From what I understand, it is because of version mismatch between org.glassfish.jersey.media and com.fasterxml.jackson.

How can I best solve this? All I need is the ability to parse LocalDate in this kind of scenario:

  public class A implements Serializable{    LocalDate date;    private List<B>;  }    

And then use it like this:

  @POST  @Consumes(MediaType.APPLICATION_JSON)  public String readListA(List<A> listA) {      ...  }    

And I don't seem to find the right Maven dependencies that can do this.(I either get null on the sublist or on localDate) Thank you for help :)

Maybe adding my grizzly server configuration will help also:

  public class Main {  // Base URI the Grizzly HTTP server will listen on  public static final String BASE_URI = "http://localhost:8080/myapp/";      static class SimpleApiServer extends ResourceConfig {      public SimpleApiServer() {          register(LoggingFilter.class);          register(JacksonFeature.class);            property(ServerProperties.TRACING, "ALL");          property(ServerProperties.TRACING_THRESHOLD, "VERBOSE");            packages("webapp");      }  }      public static HttpServer startServer() {        ResourceConfig rc = new SimpleApiServer();        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);  }    public static void main(String[] args) throws IOException {      final HttpServer server = startServer();      System.out.println(String.format("Jersey app started with WADL available at "              + "%sapplication.wadl\nHit enter to stop it...", BASE_URI));      System.in.read();      server.stop();  }    

No comments:

Post a Comment