Announcement Announcement Module
Collapse
No announcement yet.
Help: upgrade to spring-mongo 1.1.1 and no converter issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help: upgrade to spring-mongo 1.1.1 and no converter issue

    Hello all,

    I am doing an upgrade to the new 1.1.1 spring.data.mongo release. after that the i alwasys got:

    <pre>
    Caused by: org.springframework.core.convert.ConverterNotFound Exception: No converter found capable of converting from type com.mongodb.BasicDBObject<?, ?> to type com.XXX.domain.XXXEntity
    at org.springframework.core.convert.support.GenericCo nversionService.handleConverterNotFound(GenericCon versionService.java:475)
    at org.springframework.core.convert.support.GenericCo nversionService.convert(GenericConversionService.j ava:175)
    at org.springframework.core.convert.support.GenericCo nversionService.convert(GenericConversionService.j ava:154)
    </pre>

    my mongoconfig is below (changed to the new 1.1.1 base class). Several things are different from the 1.0.x release.
    1) i was required to write a Joda DateTime converter which i do not have to in the 1.0
    2) the customConversion bean had been called three times and i saw the converters registered.
    3) my converters are from DBobject to entities, but even if I change them to BasicDBObject to entities. i still get the same exception. so something wrong with the registration?

    <pre>
    @Configuration
    public class MongoConfig extends AbstractMongoConfiguration {
    @Inject
    private Environment env;

    @Bean
    @Override
    public Mongo mongo() throws Exception {
    return new Mongo(env.getProperty("mongo.host"), env.getProperty("mongo.port", Integer.class, 27017));
    }

    @Override
    public String getMappingBasePackage() {
    return "com.xxx";
    }

    @Override
    public String getDatabaseName() {
    return env.getProperty("mongo.database");
    }

    @Bean
    @Override
    public CustomConversions customConversions() {
    List<Converter<?, ?>> converters = new ArrayList<Converter<?, ?>>();
    converters.add(new JodaDateTimeWriteConverter());
    converters.add(new JodaDateTimeReadConverter());
    converters.add(new XXXReadConverter());
    converters.add(new XXXWriteConverter());
    return new CustomConversions(converters);
    }

    }
    </pre>
Working...
X