---
title: "Context [/XXX(我的项目)] startup failed due to previous errors "
author: "catlovefox"
date: "2010-04-23T14:28:10Z"
tags: ["Flex", "Myeclipse", "Servlet", "Spring", "Web"]
categories: ["企业架构"]
slug: "context-xxx-startup-failed-due-to-previous-errors"
draft: false
lastmod: "2010-04-23T14:31:38Z"
id: 651255
url: "https://catlovefox.iteye.com/blog/651255"
---

今天配置Spring来显示flex的项目。  
出现了这个错误。  
Context \[/XXX(我的项目)] startup failed due to previous errors

web.xml中：

&lt;context-param&gt;  
      &lt;param-name&gt;contextConfigLocation &lt;/param-name&gt;  
      &lt;param-value&gt;/WEB-INF/applicationContext.xml &lt;/param-value&gt;  
&lt;/context-param&gt;  
&lt;listener&gt;  
      &lt;listener-class&gt;  
       org.springframework.web.context.ContextLoaderListener   
      &lt;/listener-class&gt;  
&lt;/listener&gt;

\----------------------  
去掉  
&lt;listener&gt;  
      &lt;listener-class&gt;  
       org.springframework.web.context.ContextLoaderListener   
      &lt;/listener-class&gt;  
&lt;/listener&gt;

就可以不报这个错误，但是，却不能使用spring链接。

\-----------------------------------

原来是因为：

org.springframework.web.context.ContextLoaderListener   
是在Servlet2.4容器上才有的.以前版本是没有的.你看看你使用的容器是否是Servlet2.4,不是的话.  
以前版本是这样用的.  
&lt;servlet&gt;  
   &lt;servlet-name&gt;SpringContextServlet &lt;/servlet-name&gt;  
   &lt;servlet-class&gt;org.springframework.web.context.ContextLoaderServlet &lt;/servlet-class&gt;     
   &lt;load-on-startup&gt;1 &lt;/load-on-startup&gt;  
&lt;/servlet&gt;

 

\------------------------------

删除&lt;listener&gt;  
      &lt;listener-class&gt;  
       org.springframework.web.context.ContextLoaderListener   
      &lt;/listener-class&gt;  
&lt;/listener&gt;  
用上边的替代，即可。

\--------------------------------------

ps:确定

你可能把不要的包也导进去了或是哪个必需的包没导入,以下是必需包：  
Spring包（9个）:   
commons-dbcp.jar、commons-pool.jar、spring.jar、spring-beans.jar、  
spring-context.jar、spring-core.jar、spring-dao.jar、  
spring-hibernate3.jar、spring-web.jar。  
struts2.0包（6个）:commons-logging-api-1.1.jar、freemarker-2.3.8.jar   
ognl-2.6.11.jar、struts2-core-2.0.8.jar、  
struts2-spring-plugin-2.0.11.2.jar、xwork-2.0.3.jar   
hibernate包:myeclipse工具自动添加生成导入。

 

\---------------------

ps2:还要确定，导入jar

在Spring MVC开发的时候，如果从Spring 1.2.x 迁移到Spring 2.0版本的时候，可能会碰到类似于  
java.lang.NoSuchMethodError: org.springframework.beans.factory.config.ConfigurableListableBeanFactory.registerScope(Ljava/lang/String;Lorg/springframework/beans/factory/config/Scope;)V  
的错误，原因就在于这两个版本的API发生了变化。  
由于Spring API依赖其他的包，比如Jakarta Commons下面的包，所以在版本升级的时候，要同时升级其他依赖的包，特别是版本从1升级到2的情况下，更要小心。  
预祝大家Spring开发顺利！