org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/ApplicationContext.xml]; nested exception is java.lang.NullPointerException2013-5-23 10:28:41 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: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/ApplicationContext.xml]; nested exception is java.lang.NullPointerException
配置 spring 启动 Tomcat报的错
Spring异常Tomcat

解决方案 »

  1.   

    ApplicationContext.xml首字母应该小写,如果没有特殊指定的话。
      

  2.   

    ApplicationContext.xml放在什么位置的
      

  3.   

    我自己写了一个放在 web_inf下、是大写
      

  4.   

    web.xml是这么写的
    <?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">
    <display-name></display-name>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <!-- spring的监听以及配置文件加载信息 -->
    <context-param>
    <param-name>contextConfigLocation</param-name>      
     <!-- 上面配置的spring配置文件的路径,区分大小写 -->
    <param-value>WEB-INF/ApplicationContext.xml</param-value>
    <!-- <param-value>classpath:ApplicationContext.xml</param-value> -->
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener> 
        <servlet>
          <servlet-name>testServlet</servlet-name>   
          <servlet-class>org.yhb.test.TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>  
         <servlet-name>testServlet</servlet-name>    
         <url-pattern>/*</url-pattern>    
         </servlet-mapping> </web-app>
      

  5.   

    贴一下ApplicationContext.xml,它是BeanDefinitionStoreException,和bean的定义存储有关
      

  6.   

    ApplicationContext.xml  贴出来看一下
      

  7.   


    <?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:context="http://www.springframework.org/schema/context"
    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-2.5.xsd http: /
    www.springframework.org / schema / context http: /
    www.springframework.org / schema / context / spring-context-2.5.xsd
    http: / www.springframework.org / schema / aop http: /
    www.springframework.org / schema / aop / spring-aop-2.5.xsd

      http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <!-- 这个地方开始放置所有bean的配置信息 -->
    <!--配置jdbc.properties文件的位置信息,路径还是区分大小写 -->
    <bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations" value="WEB-INF/jdbc.properties" />
    </bean>   

    <!-- 读取jdbc.properties文件,配置数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="${driver}" />
    <property name="url" value="${url}" /> <property name="username" value="${user}" />
    <property name="password" value="${password}" />   <!-- 数据库连接池配置 -->
    <property name="initialSize" value="60" /><!-- 初始化连接数量 -->
    <property name="maxActive" value="100" /><!-- 最大连接数量 -->
    <property name="maxIdle" value="50" /><!-- 最大空闲连接数量 -->
    <property name="minIdle" value="10" /><!-- 最小空闲连接数量 -->
    </bean>

    <!-- 配置实现类,注入数据源 -->
    <bean id="ITestTableDAOImpl" class="org.yhb.vo.impl.ITestTableDAOImpl">
    <property name="dataSource" ref="dataSource" />
    </bean>  <!-- 配置service类,注入上面的实现类 -->

    <bean id="ITestTableDAOService" class="org.yhb.vo.service.ITestTableDAOService">
    <property name="testImpl" ref="ITestTableDAOImpl" />
    </bean>
    </beans> 
      

  8.   

    楼主贴一下调用ApplicationContext.xml的java语句。和ApplicationContext.xml的路径。
      

  9.   

    applicationContext.xml配置文件一般放在src目录下,这样就不会因为路径问题出现错误,另外记得在web.xml配置文件中配置上spring的监听,望对楼主有帮助、、、、、、、
      

  10.   

    估计是在解析properties文件的时候出的问题吧,楼主可以断点到locations注值那里看看