gpt4 book ai didi

spring - ApplicationEventMulticaster 未使用 mongo 的 spring-data 初始化

转载 作者:行者123 更新时间:2023-12-01 12:54:48 24 4
gpt4 key购买 nike

我目前在启动 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

背景:

  • 我的 spring-security authenticationProvider 需要一个 hazelcast 映射
  • hazelcast 在启动时从基于 mongo 的 spring-data 的 mapstore 加载数据
  • spring 数据要使用 ApplicationEventMulticaster
  • 还没有。

据我所知,Multicaster 是在调用 configurableApplicationContext 上的 init() 时创建的,这似乎发生在 spring 安全性之后。 (紧接着...)

我可以强制应用程序上下文提前设置多播器还是稍后设置 hazelcast?

最佳答案

不确定它是 Spring Security 还是一般的 Spring 问题,但是 Spring Security 类在 configurableApplicationContext 上的 init() 被调用之前被初始化(所以在 ApplicationEventMulticaster 已创建)。

我认为这是一个重要的问题,因为解决这个问题的唯一方法是从我的安全实现中删除依赖注入(inject),并在第一次使用时从应用程序上下文中手动获取所有内容(我现在已经这样做了)。

我可能会为它提出一个 Jira 问题。

关于spring - ApplicationEventMulticaster 未使用 mongo 的 spring-data 初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10401221/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com