Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

JsonMappingException when EntityFilteringFeature used with JacksonFeature #3574

Open
amichair opened this issue Jun 6, 2017 · 2 comments
Open

Comments

@amichair
Copy link

amichair commented Jun 6, 2017

Using jersey-container-servlet 2.25 and jersey-media-json-jackson 2.25 (which uses jackson 2.8.4).

The application ResourceConfig includes:

// gzip support
register(EntityFilteringFeature.class);
EncodingFilter.enableFor(this, GZipEncoder.class);
// jackson serializer
register(JacksonFeature.class);
// application classes
packages("com.example");

if only one of JacksonFeature or EntityFilteringFeature is used, everything is ok. But when both are used together, Jackson serialization fails with

JsonMappingException: Can not resolve PropertyFilter with id 'java.util.LinkedHashMap'; no FilterProvider configured

There are a few similar issues reported in e.g. stackoverflow, with very elaborate workarounds. The workaround I found is modifying the custom ObjectMapper used in the application to use a no-op filter:

SimpleFilterProvider filterProvider = new SimpleFilterProvider();
filterProvider.setDefaultFilter(new SimpleBeanPropertyFilter.SerializeExceptFilter(Collections.emptySet()));
mapper.setFilterProvider(filterProvider);

So it seems like adding gzip support to a jersey+jackson application breaks the serialization.

I'm not 100% sure the issue is with Jersey rather than Jackson, but I reported this first at FasterXML/jackson-databind#1645 and they pointed the finger at you :-)

@crizo23
Copy link

crizo23 commented Nov 22, 2017

The key to reproducing this is "Can not resolve PropertyFilter with id 'java.util.LinkedHashMap'". There seems to be a problem serializing Java Map collections with EintityFiltering. I logged some additional detail here: https://github.com/jersey/jersey/issues/3732

And also, while your workaround prevents the exception from being thrown, it also seems to disable the SelectableEntityFilteringFeature/EntityFilteringFeature completely.

@xtermi2
Copy link

xtermi2 commented Mar 2, 2018

same issue here :(
please fix it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants