Quantcast

ShiroFilterFactoryBean and a spring data mongodb realm

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ShiroFilterFactoryBean and a spring data mongodb realm

jason
Hi All,
I'm using shiro with spring data and mongodb in a web application.
 I've created a simple mongodb realm which is also configured via spring.

I'm also using the spring DelegatingFilterProxy along with ShiroFilterFactoryBean.

when I try to use it I invariably get:
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext

the problem is that spring-data-mongodb requires a spring ApplicationEventMulticaster to have been initialised before it can be used.

ShiroFilterFactoryBean is a beanPostProcessor, and as such, during initialisation, spring attempts to configure its realms(and hence my realm and spring data mongo based userDao).
it fails because ApplicationEventMulticaster has not yet been created.

the relevant part in spring.
org.springframework.context.support.AbstractApplicationContext.refresh()

...
try {
...
                registerBeanPostProcessors(beanFactory);

                // Initialize message source for this context.
                initMessageSource();

                // Initialize event multicaster for this context.
                initApplicationEventMulticaster();

                // Initialize other special beans in specific context subclasses.
                onRefresh();
                registerListeners();
...
            }

you can see that the BeanPostProcessors are setup before initApplicationEventMulticaster() is ever called.


so my query is, whats the best way to solve this? whats the sanest option?

Thanks
Loading...