Open spring-projects-issues opened 8 years ago
Karsten Ludwig Hauser commented
I also stepped into this trying to upgrade my system with new spring data rest packages:
compile("org.springframework.data:spring-data-rest-core:2.6.0.BUILD-SNAPSHOT")
compile("org.springframework.data:spring-data-rest-webmvc:2.6.0.BUILD-SNAPSHOT")
so the error here is quite the same with an missing GeoModule-object in RepositoryRestMvcConfiguration.
Caused by: java.lang.NullPointerException: null
at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:688) ~[jackson-databind-2.6.4.jar:2.6.4]
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.basicObjectMapper(RepositoryRestMvcConfiguration.java:801)
Is there maybe a package missing which initializes the GeoModule?
Shijun Kong commented
hit the same issue
it seems to related to autowired and order of bean initialization
a work around, create a local validator, and inject it manually, not using autowired
@Bean
@Autowired
public ValidationRepositoryRestConfigurer validationRepositoryRestConfigurer(ApplicationContext applicationContext) {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.setApplicationContext(applicationContext);
validator.afterPropertiesSet();
return new ValidationRepositoryRestConfigurer(validator);
}
public static class ValidationRepositoryRestConfigurer extends RepositoryRestConfigurerAdapter {
private org.springframework.validation.Validator localValidator;
public ValidationRepositoryRestConfigurer(Validator localValidator) {
this.localValidator = localValidator;
}
@Override
public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {
validatingListener.addValidator("beforeCreate", localValidator);
}
}
John Hall commented
This ticket can be closed. While using Spring Boot 1.3.1, we had to set the validators manually because it wasn't finding them as they should. As we upgraded to newer versions, the auto-discovery of these methods started working properly and we no longer needed to set them manually, so this is no longer an issue
John Hall opened DATAREST-807 and commented
Hello, we setup spring Validation for our domain (data) objects in the following way with the previous SDR release:
This worked well because it basically turned on validation for all of our domain objects with just a few lines of code. Now it's possible that this is not the proper way to setup validation of our domains, but the documentation in this area is sparse, we found something that worked and we went with it. If this is not the proper way to setup validation for our domains, please let us know. Now with the latest Hopper release, we're seeing the following exceptions thrown with the root cause being an NPE:
Affects: 2.5.1 (Hopper SR1)