nested exception is java.io.FileNotFoundException: Could not open ServletContext resource

  1. <context-param>  
  2.     <param-name>contextConfigLocation</param-name>  
  3.     <param-value>classpath:applicationContext.xml</param-value>  
  4. </context-param>  

 

注意这段配置尽量写在靠前的位置,因为在tomcat启动后web项目会先初始化上下文,我们这段配置正是指定了上下文配置的文件位置,在上下文初始化完成之后才应当继续加载其余各种配置,而我们的springMVC的servlet仅仅是springMVC框架的相关配置,就好比struts2的配置一样,项目整体还是由spring去管理的。

 

学习自:http://blog.csdn.net/wlwlwlwl015/article/details/48134763

报错信息:

月 10, 2017 9:31:12 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 二月 10, 2017 9:31:13 下午 org.apache.catalina.core.StandardContext listenerStart 严重: 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 ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]  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:4812)  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)  at java.util.concurrent.FutureTask.run(FutureTask.java:266)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  at java.lang.Thread.run(Thread.java:745) Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]  at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)  ... 21 more

二月 10, 2017 9:31:13 下午 org.apache.catalina.core.StandardContext startInternal 严重: One or more listeners failed to start. Full details will be found in the appropriate container log file 二月 10, 2017 9:31:13 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom 信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [179] milliseconds. 二月 10, 2017 9:31:13 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/SpringUnit01] startup failed due to previous errors 二月 10, 2017 9:31:13 下午 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 二月 10, 2017 9:31:13 下午 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:4859)  at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)  at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:224)

转载于:https://www.cnblogs.com/21heshang/p/6388090.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值