gpt4 book ai didi

Java Spring 应用程序 - 向监听器 i 发送上下文初始化事件的异常

转载 作者:行者123 更新时间:2023-11-29 05:06:26 25 4
gpt4 key购买 nike

我有一个 java spring 应用程序,它使用带有以下 spring jar 的 spring 3.0.7

spring-aop-3.0.7.RELEASE.jar

spring-asm-3.0.7.RELEASE.jar

spring-beans-3.0.7.RELEASE.jar

spring-context-3.0.7.RELEASE.jar

spring-core-3.0.7.RELEASE.jar

spring-data-jdbc-core-1.0.0.RELEASE.jar

spring-expression-3.0.7.RELEASE.jar

spring-jdbc-3.0.7.RELEASE.jar

spring-tx-3.0.7.RELEASE.jar

spring-web-3.0.7.RELEASE.jar

此应用程序在许多 VM 中运行良好。但是在一个虚拟机中,它会在服务器启动时抛出以下异常。

Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener

感谢任何指点。

整个异常堆栈跟踪:

INFO: Initializing Spring root WebApplicationContext
May 13, 2015 3:28:01 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testCacheLoader': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.util.localization.LoadLocaleMessage com.caching.testCacheLoader.llm; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadLocaleMessage': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.common.dao.CommonDAO com.util.localization.LoadLocaleMessage.commonDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public com.caching.testCache com.common.dao.CommonDAOImpl.testCache; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testCache': Invocation of init method failed; nested exception is com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)

@PostConstruct
public void init() {
cache = CacheBuilder.newBuilder().maximumSize(100)
.refreshAfterWrite(8, TimeUnit.HOURS).removalListener(listener)
.build(loader);

ScheduledExecutorService ses = Executors
.newSingleThreadScheduledExecutor();

ses.scheduleWithFixedDelay(new Runnable() {
public void run() {
for (String key : cache.asMap().keySet()) {
cache.refresh(key);
logger.info("Refreshing cache . . . . ");
}
}
}, 0, 5, TimeUnit.MINUTES);

try {
cache.get("LOCALIZATION");
} catch (ExecutionException e) {
e.printStackTrace();
}
}

最佳答案

查看异常的最后一部分:

Error creating bean with name 'testCache': 
Invocation of init method failed; nested exception is
com.google.common.util.concurrent.UncheckedExecutionException:
java.lang.NullPointerException

testCache bean 的初始化方法看起来如何 - 这就是错误所在(NullPointerException)。

干杯,

关于Java Spring 应用程序 - 向监听器 i 发送上下文初始化事件的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30224712/

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