Anybody knows how to disable autodiscovery and manually register JacksonFeature, just to be completely sure that in case there are several providers in the classpath that is the one used?
Everything is working by default, with the lines of the following helper commented. Then I try to register JSON provider by hand, so I uncomment lines and specify
private void disableAutoDiscoveryAndUseJacksonProvider(ResourceConfig config) {
config.property(CommonProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
// config.property(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
// config.property(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, false);
config.register(JacksonFeature.class);
}
context.addServlet(new ServletHolder(new ServletContainer(config)), "/*");
Same logic works when using a client with:
javax.ws.rs.client.Client client =
javax.ws.rs.client.ClientBuilder.newBuilder().register(JacksonFeature.class).build();
EDIT: As I cannot work it out, I'm trying to replicate default behaviour in an explicit way.
ServletHolder holder = new ServletHolder(new ServletContainer()) // No Config
Called that way, and putting just Jackson in the path the application works (objects deserialize correctly) But if I make a ResourceConfig explicit as in:
ResourceConfig config = new ResourceConfig();
//config.property(X,default)
ServletHolder holder = new ServletHolder(new ServletContainer(config));
I get a deserializing error
I try to mimic the default behaviour explicitly by specifying all the combinations of CommonProperties.* like config.property(X,default), config.property(Y,default) but still no luck, any ideas what is happening behind?