Jan 9th, 2013, 09:19 PM
spring-data-mongo repo cant be initialised if referenced via a beanPostProcessor
briefly, I'm trying to use spring-data-mongo in a web context along with apache shiro.
using spring 3.2.0-release
shiro uses an instance of a beanPostProcessor to init itself. This in turn eventually references a spring-data-mongo based userDao in my custom shiro realm.
The autoProxy versions of the repository (extends mongoRepository etc) dont work at all when initialised like this,
so I tried extending SimpleMongoRepository in my DAO.
this works when its allowed to start normally, but not via a beanPostProcessor.
the exception is java.lang.IllegalStateException: ApplicationEventMulticaster not initialized
the root cause seems to be that in order to instantiate a SimpleMongoRepository I need to call MongoRepositoryFactory(template).<User, String>getEntityInformation(User.class)
this method eventually lands in org.springframework.data.mapping.context.AbstractM appingContext,
where it creates a new PersistentEntity and then tries to publish an ApplicationEvent.
unfortunately beanPostProcessors seem to be run before ApplicationEventMulticaster is still ever initialized so cannot work if they try to raise ApplicationEvents during startup.
Is this a problem with my setup? or is it a fault of spring-data-mongo for attempting to raise an event here?
or a fault in spring for not making the ApplicationEventMulticaster available for entities initialised from a beanPostProcessor?
how best to proceed?