2010-11-5 11:36:08 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:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4323)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4771)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1124)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1047)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:542)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1390)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:355)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:998)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:990)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:275)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:424)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:648)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:415)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:118)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 44 more
实在整不出来了

解决方案 »

  1.   

    你配置了这个没?<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
      

  2.   

    nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]看下applicationContext路劲对不
      

  3.   

    我就是放在src下,应该没问题吧,而且把各种路径都试了一遍,在web.XML里也配置过了,还是不行
      

  4.   

    楼主先在web.xml中添加一个
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:application.xml</param-value>
    </context-param>
    这个用来指定你的配置文件路径,默认是应该放到web-inf下的。祝你好运!
      

  5.   

    applicationContext.xml 文件没有找到,你看看你的路径
      

  6.   

    试过了,不行,我感觉不是路径的错,有可能是JAR包的问题
      

  7.   

    我猜想 classpath: 表示要在类路径中找得到它,如果你给的 URL 是 /WEB-INF/applicationContext.xml,那就表示,它就应该出现在 src/WEB-INF/applicationContext.xml 这个位置(这里假设 src 是Java源文件夹)。
      

  8.   


    你那是单纯的Spring,还是SSH整合?
      

  9.   


    顶,楼主,applicationContext.xml路径错误
      

  10.   

    struts2的配置文件里和applicationContext里的ref要对上! 一个字母都不能错,大小写也要对应,加载的时候注意要配置完善,不如,有一个bean.hbm.xml.则就在applicationContext配置一个,不要有3个bean就配置了一个就启动,然后再配置3个再从新启动,否则,从新加载。同时,web.xml也要配置好路径,把所有需要的jar包引入,别落下与数据库连接的包。再要出错,你就可以从一楼跳下来了!
      

  11.   

    恩,如果实在不行,建议楼主用MyEclipse自带的框架,这样很多配置文件就自动的生成好了,而且可以避免很多麻烦
      

  12.   

    这是我配置的路劲<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
    </context-param>那现在applicationContext.xml应该放在哪?src下还是WEB-INF下?
      

  13.   

    貌似换了一个错误2010-11-5 13:30:28 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 class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

      

  14.   

    web.xml中加:
    <context-param>
        <param-name>contextConfigLocation </param-name>
        <param-value>/WEB-INF/classes/applicationContext.xml </param-value>
    </context-param>
      

  15.   

    如果用的MyEclipse那applicationContext.xml还是放在src下
      

  16.   

    换错误了,这还是路径的错误么?好想是说我XML里面第10行有错了严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/classes/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.这是我applicationContext.xml前11行代码,有什么错么?<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans "
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:aop="http://www.springframework.org/schema/aop "
    xmlns:tx="http://www.springframework.org/schema/tx "
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                         http://www.springframework.org/schema/beans/spring-beans.xsd
                         http://www.springframework.org/schema/tx
                         http://www.springframework.org/schema/tx/spring-tx.xsd
                         http://www.springframework.org/schema/aop
                         http://www.springframework.org/schema/aop/spring-aop.xsd ">
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
      

  17.   

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"...
    那啥c3p0需要导入什么jar不?
      

  18.   

    应该是加载applicationContext.xml路径有问题,建议用classpath试下
      

  19.   

    贴代码   web.xml的代码
      

  20.   


    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/applicationContext.xml </param-value>
    </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    </web-app>
      

  21.   

    applicationContext是放在classes下面
    一般放在src下会自动编译到classes,你看一下classes下面有没有applicationContext.xml
      

  22.   

    跑去工程发布目录中 看web-info里有没这个文件.. 就是没找到这文件嘛,你配置在哪个路径  就放哪个路径.
      

  23.   

     <param-value>/WEB-INF/classes/applicationContext.xml </param-value>
    后面多了个空格,简单的写
     <param-value>classpath:app*.xml</param-value>