最新消息:关注【太平洋学习网】微信公众号,可以获取全套资料,【全套Java基础27天】【JavaEE就业视频4个月】【Android就业视频4个月】

解决严重: Exception sending context initialized event to listene

扩展 太平洋学习网 浏览 评论

ssm框架搭建中遇到class path resource [spring/applicationContext.xml] cannot be opened because it does not exist错误通常是因为你的xml配置文件可能在复制过程中,在项目spring目录下并不存在applicationContext.xml,因此进入eclipse所在项目的目录中的文件是否存在,如果存在就看web.xml下是否有contextConfigLocation配置,文章尾部有讲到。

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
 at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
 at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
 at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
 at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
 at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
 at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
 at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
 ... 21 more
八月 30, 2017 12:08:00 下午 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
八月 30, 2017 12:08:00 下午 org.apache.catalina.core.StandardContext startInternal
严重: Context [/laypage] startup failed due to previous errors
八月 30, 2017 12:08:00 下午 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
八月 30, 2017 12:08:00 下午 org.apache.catalina.core.StandardContext listenerStop
严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
 at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
 at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:908)
 at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:884)
 at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
 at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
 at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
 at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
 at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
 at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)
八月 30, 2017 12:08:00 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/laypage] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
八月 30, 2017 12:08:00 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/laypage] registered the JDBC driver [com.mysql.fabric.jdbc.FabricMySQLDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
八月 30, 2017 12:08:00 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/laypage] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
八月 30, 2017 12:08:00 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-80"]

 遇到以上ContextLoaderListener或者Caused by: java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist,那么请按照以下步骤解决。

1:检查web.xml里面是否有启动spring的contextConfigLocation配置,代码如下。

 <!-- 启动spring -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:spring/applicationContext.xml</param-value>
 </context-param>
 
 <!-- applicationContext -->
 <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

2:请到项目所在的目录src/main/resources/spring下面查看是否存在applicationContext.xml等相关配置文件,如果没有就要添加到resources目录下面去。

来源网站:太平洋学习网,转载请注明出处:http://www.tpyyes.com/a/kuozhan/197.html
"文章很值,打赏犒劳作者一下"
微信号: Javaweb_engineer

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

与本文相关的文章

发表我的评论
取消评论

表情

您的回复是我们的动力!

  • 昵称 (必填)

网友最新评论