Dropwizard's bootstrap object has an ObjectMapper in it that we've been trying to get to understand java8 datatypes (Optional / DateTime / etc). Initially we thought the dropwizard-java8 bundle would do this for us, as it's setting up bootstrap.getObjectMapper() with the appropriate jackson modules, and allows us to return Optional resources. However, in order to return objects that contain Optionals it appears we need to do the following in our Application's run() method:
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(objectMapperWithAppropriateModules);
environment.jersey().register(provider);
It feels like a bug in dropwizard the the boostrap ObjectMapper is not being used by the reflection-instantiated JacksonJaxbJsonProvider? We're seeing this behavior with Dropwizard 0.9.1 and dropwizard-java8 0.9.0-1
Dropwizard's bootstrap object has an ObjectMapper in it that we've been trying to get to understand java8 datatypes (Optional / DateTime / etc). Initially we thought the
dropwizard-java8bundle would do this for us, as it's setting up bootstrap.getObjectMapper() with the appropriate jackson modules, and allows us to return Optional resources. However, in order to return objects that contain Optionals it appears we need to do the following in our Application's run() method:It feels like a bug in dropwizard the the boostrap ObjectMapper is not being used by the reflection-instantiated JacksonJaxbJsonProvider? We're seeing this behavior with Dropwizard 0.9.1 and dropwizard-java8 0.9.0-1