当我的spring应用程序启动时,我目前遇到以下异常:
2012-04-27 17:42:51,021 ERROR [main] com.hazelcast.impl.FactoryImpl - /10.188.31.125:54327 [dev] ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.context.support.ClassPathXmlApplicationContext@1fd0fafc: startup date [Fri Apr 27 17:42:46 CEST 2012]; root of context hierarchy
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.context.support.ClassPathXmlApplicationContext@1fd0fafc: startup date [Fri Apr 27 17:42:46 CEST 2012]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:337) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:324) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:263) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:364) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:570) ~[spring-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:247) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:364) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:570) ~[spring-core-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:247) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:165) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:65) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate.determineCollectionName(MongoTemplate.java:1494) ~[spring-data-mongodb-1.0.1.RELEASE.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate.findAll(MongoTemplate.java:959) ~[spring-data-mongodb-1.0.1.RELEASE.jar:na]
at net.bigpoint.globalchat.hazelcast.MongoMapStore.loadAllKeys(MongoMapStore.java:59) ~[classes/:na]
at com.hazelcast.impl.concurrentmap.MapStoreWrapper.loadAllKeys(MapStoreWrapper.java:131) ~[hazelcast-2.0.2.jar:2.0.2]
at com.hazelcast.impl.FactoryImpl.checkInitialization(FactoryImpl.java:588) [hazelcast-2.0.2.jar:2.0.2]
at com.hazelcast.impl.FactoryImpl.getOrCreateProxyByName(FactoryImpl.java:546) [hazelcast-2.0.2.jar:2.0.2]
at com.hazelcast.impl.FactoryImpl.getMap(FactoryImpl.java:514) [hazelcast-2.0.2.jar:2.0.2]
at com.hazelcast.impl.FactoryImpl$HazelcastInstanceProxy.getMap(FactoryImpl.java:240) [hazelcast-2.0.2.jar:2.0.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_27]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_27]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_27]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_27]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactory
背景:
据我所知,在调用configurableApplicationContext上的init()时创建了Multicaster,这似乎发生在spring安全性之后。 (紧接着......)
我可以强制应用程序上下文更早地设置多播器或稍后设置hazelcast吗?
答案 0 :(得分:4)
在调用init()
configurableApplicationContext
之前(在ApplicationEventMulticaster
创建之前),不确定它是Spring安全问题还是一般Spring问题,而是初始化Spring安全类。
我认为这是一个重要的问题,因为解决这个问题的唯一方法是从我的安全实现中删除依赖注入,并在第一次使用时从应用程序上下文中获取所有内容(我现在已经这样做了)。
我可能会为它提出一个Jira问题。