BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the Applic

落日映苍穹つ 2022-07-12 04:43 209阅读 0赞

1、错误描述

  1. 严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
  2. java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  3. at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
  4. at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)
  5. at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
  6. at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)
  7. at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:581)
  8. at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
  9. at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5115)
  10. at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5779)
  11. at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)
  12. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:159)
  13. at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
  14. at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
  15. at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
  16. at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1260)
  17. at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:2002)
  18. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
  19. at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  20. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  21. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  22. at java.lang.Thread.run(Thread.java:745)

2、错误原因

  1. 无法获取到ApplicationContext

3、解决办法

(1)测试spring时添加

  1. ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

(2)将applicationContext.xml改为ApplicationContext.xml

发表评论

表情:
评论列表 (有 0 条评论,209人围观)

还没有评论,来说两句吧...

相关阅读