`
小杨学JAVA
  • 浏览: 884800 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

严重: Error listenerStart

 
阅读更多

2007-5-31 14:27:13 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2007-5-31 14:27:13 org.apache.catalina.core.StandardContext start
严重: Context [/testWSH] startup failed due to previous errors

教程的作者在录制教程时也遇到了此问题,但是他删了一个jar包后就没事了,可是我的一直无法正常启动,从昨天到现在一天的时间都在研究这个问题,也“百 度”到了很多有关此问题的信息,但是都没有很明确的解决方案。现在此问题已经解决,而且基本肯定问题所在,所以将解决方案写出来以供参考。

有一种解决方案是把web.xml文件中的<o:p></o:p>

<listener> <listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
listener>
改为
<servlet>
<servlet-name>SpringContextServletservlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
servlet-class>
<load-on-startup>1load-on-startup>
servlet><o:p></o:p>

但这种方法可能会出现其他问题(网上又说会导致其他文件无法打开)。
<o:p></o:p>

我的最终解决方案如下:
我用的是tomcat5.5,配置了日志之后打印出下列信息:
ERROR main org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
Caused by:
java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
at java.lang.Class.getConstructor0(Class.java:2640)
at java.lang.Class.getDeclaredConstructor(Class.java:1953)
……

从日志信息看问题已经很明显了,是 applicationContext.xml 的 dataSource 问题。

<bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource"></bean><bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource"></bean>改为
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="dataSource"></bean><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
之后问题得到解决。?<o:p></o:p>

出现"Error listenerStart"一般是applicationContext.xml中的bean加载有问题。在用eclipse做webwork + spring + hibernate 的项目时一般都是用Myeclipse自动生成那些配置文件,而有些相关的jar或者文件并没有加载在至项目中,以至引出奇怪的问题,又因为是自动生成的东西所以往往会忽略一些文件,而问题确恰恰是这些生成的文件所致,所以自动化的东西也未必一定是正确的,呵呵……<o:p></o:p>

org.springframework.jdbc.datasource.DriverManagerDataSource 不可以使用连接池。org.apache.commons.dbcp.BasicDataSource作为注入的DataSource源,为了使用 DBCP的功能,必须要将commons-dbcp.jar加入CLASSPATH中,另外还需要commons-pool.jar和commons- collections.jar,这些都可以在Spring的lib目录下找到。

org.springframework.jdbc.datasource.DriverManagerDataSource并没有提供连接池的功能,只能作作简单的单机连接测试。
使用org.apache.commons.dbcp.BasicDataSource时缺少commons-pool.jar所以会出现如题的问题。 <o:p></o:p>

再次修正:<o:p></o:p>

昨天又遇到此问题,解决的办法是删除无用的jar。<o:p></o:p>

工程是 springhibernate+tomcat<st1:chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on">5.5.25</st1:chsdate>,jar都是用eclipse自动加载的,很多jar明显的用不到,例如:ibatis,toplink等。将无用的jar删除后问题解决。<o:p></o:p>

<o:p>?</o:p>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics