You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by jason <ja...@hardlight.com.au> on 2013/01/09 06:21:46 UTC

ShiroFilterFactoryBean and a spring data mongodb realm

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



--
View this message in context: http://shiro-user.582556.n2.nabble.com/ShiroFilterFactoryBean-and-a-spring-data-mongodb-realm-tp7578141.html
Sent from the Shiro User mailing list archive at Nabble.com.