web工程之启动时spring的dtd错误 [/WEB-INF/applicationContext.xml

来源:互联网 发布:加权并查集算法 编辑:程序博客网 时间:2024/05/02 00:54
I have put in the latest dom4j-1.6.1, and Spring 1.2.5, and Hibernate 3.0.5, and I am still getting the following message. Any other thing I can do? Thank you.


2005-10-13 10:14:04,237 INFO [org.springframework.beans.factory.support.Default ListableBeanFactory] - Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [propertyConfigurer,dataSource,sessionFactory,tran sactionManager,userDAO,userManagerTarget,userManag er]; root of BeanFactory hierarchy}
2005-10-13 10:14:04,237 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect
org.hibernate.MappingException: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect
at org.hibernate.cfg.Configuration.addInputStream(Con figuration.java:408)
at org.springframework.orm.hibernate3.LocalSessionFac toryBean.afterPropertiesSet(LocalSessionFactoryBea n.java:608)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:962)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:354)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:223)

服务器上(这里指svn,cvs等版本控制工具)check out之后,写好自己负责的业务逻辑之后,发布到应用服务器(tomcat) ,发生了莫名其妙的错误;错误的信息如下:

2009-7-16 14:18:22 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 [newspweb-lib.xml]; nested exception is java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
   )
也没什么特别的提示,从提示的英文看上去貌似什么网络出了问题,socket什么什么的;上百度搜索了一下,解决的方法可谓五花八门,但是到头来没一个是可以搞定的;有些就说spring在启动的时候先从applicationContext文件里面声明的网络地址(如http://www.springframework.org/dtd/等)去找,如果网络上找不到(如你电脑不能上网;或公司对网络有限制,我们公司就这样,比较恶心),就到本地文件来找,这里的本地就是spring.jar这个包里面的文件;其实我发现完全 不是那么一回事,我认为spring根本就没有上网找,而是直接从本地(在包spring.jar解压后得到目录下spring/org/springframework/beans/factory/xml/spring-beans****.dtd路径下可以找到)里面找搞了半天终于找到解决的方案原来是spring配置文件的dtd出了问题

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dt
替换成
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

之后 ,问题得到了解决;归根结底就是Eclipse的插件版本的问题,这些问题真的很隐蔽,提示也很模糊,让你 哭笑不得,在这里总结一下,顶!

http://devbbs.doit.com.cn/thread-507-1-1.html

http://forum.springsource.org/archive/index.php/t-18861.html

原创粉丝点击