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)

时间: 2024-12-18 13:35:53

nested exception is java.io.FileNotFoundException: Could not open ServletContext resource的相关文章

出错: IOException parsing XML document from ServletContext resource [/cn.mgy.conig]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/cn.mgy.conig]

错误的详细内容: 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/cn.mgy.conig]; nested exception is java.io.FileNotFoundException: Could not open Se

nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog

spring单元测试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring/spring-datasource-mogon.xml]; nested exception is java.io.FileNotFoundException: class path resource [

parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not exist 报错原因是 xml名字可能写错了 原文地址:https://www.cnbl

nested exception is java.io.FileNotFoundException: class path resource [spring-mybatis.xml] cannot be opened

idea+maven+springmvc项目,做单元测试报错,找不到配置文件. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:spring-mybatis.xml"}) public class TestMybatis { private static Logger logger = LoggerFactory.getLogger(TestMybatis.cla

java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]

Maven项目,application-context.xml.db.properties文件均放置在src/main/resources目录下,Tomcat部署项目,src/main/resources目录下的配置文件默认位置为: {项目名}/WEB-INF/classes,而Spring却在项目根目录下寻找,肯定找不到,因此,配置时指定classpath目录下寻找即可.解决方案如下: 在applicationContext,xml文件下配置 <context:property-placeho

om.exception.DaoException: java.io.FileNotFoundException: D:\Users\liuyangOS2237\Workspaces\MyEclipse%2010\Zhuce\WebRoot\WEB-INF\classes\users.xml (系统找不到指定的路径。解决

com.exception.DaoException: java.io.FileNotFoundException: D:\Users\liuyangOS2237\Workspaces\MyEclipse%2010\Zhuce\WebRoot\WEB-INF\classes\users.xml (系统找不到指定的路径.) at com.dao.impl.UserDaoDom4jImpl.addUser(UserDaoDom4jImpl.java:84) at com.test.UserDaoDo

SpringBoot 上传文件突然报错 Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608

异常信息 org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.1428942566812653608.8090/work/Tomcat/localhost/ROOT] is not vali

Caused by: java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be ope

1.错误描述 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) at org.springframework.test.context.DefaultTestContext.

解决CXF的java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-soap.xml] cannot be opened because it does not exist

以下是错误信息 九月 25, 2017 8:22:04 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh 信息: Refreshing Root WebApplicationContext: startup date [Mon Sep 25 20:22:04 CST 2017]; root of context hierarchy 九月 25, 2017 8:22:04 下午 or