AnnotationConfigEmbeddedWebApplicationContext@5f395ce1 has been closed already异常

2022-06-15 14:15:21

项目运行之后使用tbscheudle扫描任务结果报异常,异常信息:

java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5f395ce1 has been closed already
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1066) ~[spring-context-4.3.23.RELEASE.jar:4.3.23.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.23.RELEASE.jar:4.3.23.RELEASE]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.getBean(TBScheduleManagerFactory.java:390) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.taskmanager.TBScheduleManager.<init>(TBScheduleManager.java:106) ~[tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.taskmanager.TBScheduleManagerStatic.<init>(TBScheduleManagerStatic.java:25) ~[tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.createStrategyTask(TBScheduleManagerFactory.java:142) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.reRunScheduleServer(TBScheduleManagerFactory.java:256) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.reRegisterManagerFactory(TBScheduleManagerFactory.java:195) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.refresh(TBScheduleManagerFactory.java:181) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.ManagerFactoryTimerTask.run(TBScheduleManagerFactory.java:454) [tbschedule-core-3.4.1.jar:na]
	at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_65]
	at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_65]

2020-01-10 12:54:08.377 info 8932 --- [erFactory-Timer] c.t.p.s.s.TBScheduleManagerFactory       : strategy 对应的配置有问题。strategy name=statusUnupdateWorkerTask
2020-01-10 12:54:08.380 info 8932 --- [erFactory-Timer] c.t.p.s.taskmanager.TBScheduleManager    : create TBScheduleManager for taskType:statusUnupdateWorkerTask
2020-01-10 12:54:08.383 info 8932 --- [erFactory-Timer] c.t.p.s.s.TBScheduleManagerFactory       : strategy 获取对应的java or bean 出错,schedule并没有加载该任务,请确认statusUnupdateWorkerTask

java.lang.IllegalStateException: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5f395ce1 has been closed already
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1066) ~[spring-context-4.3.23.RELEASE.jar:4.3.23.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.23.RELEASE.jar:4.3.23.RELEASE]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.getBean(TBScheduleManagerFactory.java:390) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.taskmanager.TBScheduleManager.<init>(TBScheduleManager.java:106) ~[tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.taskmanager.TBScheduleManagerStatic.<init>(TBScheduleManagerStatic.java:25) ~[tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.createStrategyTask(TBScheduleManagerFactory.java:142) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.reRunScheduleServer(TBScheduleManagerFactory.java:256) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.reRegisterManagerFactory(TBScheduleManagerFactory.java:195) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.TBScheduleManagerFactory.refresh(TBScheduleManagerFactory.java:181) [tbschedule-core-3.4.1.jar:na]
	at com.taobao.pamirs.schedule.strategy.ManagerFactoryTimerTask.run(TBScheduleManagerFactory.java:454) [tbschedule-core-3.4.1.jar:na]
	at java.util.TimerThread.mainLoop(Timer.java:555) [na:1.8.0_65]
	at java.util.TimerThread.run(Timer.java:505) [na:1.8.0_65]

解决:AnnotationConfigEmbeddedWebApplicationContext为什么会自动关闭,查看上方的日志发现了关闭原因
在这里插入图片描述
因爲

  • 作者:边跳舞边打代码的仔
  • 原文链接:https://blog.csdn.net/xucong996/article/details/103922613
    更新时间:2022-06-15 14:15:21