Skip to content

Bootstrap ObjectMapper not used in Jersey MessageBodyWriter #1341

@josephlbarnett

Description

@josephlbarnett

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleStale issue or pull request which will be closed soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions