I'm using the latest release of Jersey (2.13) on a glassfish server together with the latest version of jackson (version. 2.4) . I've written and registered a custom ObjectMapper, but it only collections seems to be serialized by my custom objectmapper.
I've seen a similar issue at this page: https://java.net/jira/browse/GLASSFISH-20815 but the workaround presented there did not work for me.
My jersey mapper provider class:
@Provider public class JerseyMapperProvider implements ContextResolver {
private static ObjectMapper apiMapper = null;
public JerseyMapperProvider() {
}
@Override
public ObjectMapper getContext(Class<?> type) {
System.out.println(type.toString() + " this is only printed for collections...");
if (apiMapper == null) {
apiMapper = getDefaultObjectMapper();
}
return apiMapper;
}
...
okay, suddenly it worked by adding the following features to my resourceConfig...