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

來源:互聯網
上載者:User

標籤:inf   efi   java   ring   檔案   style   ade   ready   adb   

  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)

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.