Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

StdObjectMapperFactory Bug #69

jvabob opened this Issue Feb 27, 2012 · 2 comments


None yet
3 participants

jvabob commented Feb 27, 2012

In my application I need to register some MixIn modules to deal with 3rd party library POJO's that do not have a no arg constructor. I created a jackson ObjectMapper and registered my modules. I then created an instance of StdObjectMapperFactory and used it's setObjectMapper to put my instance of ObjectMapper into the factory. I then pass the factory to the StdCouchDbConnector constructor.

createObjectMapper works just like you would expect and passes the ObjectMapper I have given the class back out.

public synchronized ObjectMapper createObjectMapper() {
    if (instance == null) {
        instance = new ObjectMapper();
    return instance;

However, the StdObjectMapperFactory.createObjectMapper(CouchDbConnector) method ignores the existence of the "instance" of ObjectMapper I gave it.

public ObjectMapper createObjectMapper(CouchDbConnector connector) {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new EktorpJacksonModule(connector, objectMapper));
    return objectMapper;

Looks to me like the to lines

    ObjectMapper objectMapper = new ObjectMapper();

should be replaced with something like

        ObjectMapper objectMapper = createObjectMapper();

Thanks in advance!


helun commented Feb 29, 2012

Yes StdObjectMapperFactory has a broken API, the historic reason is that a singleton instance could not be used together with the @documentreferences annotation. I think this might have changed with later versions of Jackson, I'll look in to it.

In the mean time I suggest that you create your own implementation of ObjectMapperFactory that work for you.

@helun did you have some time looking into it?

In combination with the current release 1.4 I needed to add a JodaModule module to the default ObjectMapper, so I came along this issue. I guess you removed the JodaModule due to Android support, but now we need to have a more convenient way of configuring the ObjectMapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment