追随Java
简单的事情重复做,就会产生累积效应!
posts - 260,  comments - 338,  trackbacks - 0
在初始化系统时出现了如下的错误:
      ERROR - Configuration.addInputStream(407) | Could not configure datastore from input stream
org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
 at org.dom4j.io.SAXReader.read(SAXReader.java:484)
 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
 at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:608)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:271)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
 at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
 at org.apache.catalina.core.StandardService.start(StandardService.java:450)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:540)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Nested exception:
java.net.ConnectException: Connection timed out: 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)
 at java.net.Socket.connect(Unknown Source)
 at sun.net.NetworkClient.doConnect(Unknown Source)
 at sun.net.www.http.HttpClient.openServer(Unknown Source)
 at sun.net.www.http.HttpClient.openServer(Unknown Source)
 at sun.net.www.http.HttpClient.<init>(Unknown Source)
 at sun.net.www.http.HttpClient.New(Unknown Source)
 at sun.net.www.http.HttpClient.New(Unknown Source)
 at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
 at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
 at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
 at java.net.URL.openStream(Unknown Source)
 at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:807)
 at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:767)
 at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:275)
 at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:841)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
 at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
 at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
 at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
 at org.dom4j.io.SAXReader.read(SAXReader.java:465)
 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
 at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:608)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:271)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
 at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
 at org.apache.catalina.core.StandardService.start(StandardService.java:450)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:540)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
ERROR - ContextLoader.initWebApplicationContext(177) | Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
org.hibernate.MappingException: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:408)
 at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:608)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:271)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
 at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:910)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:873)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
 at org.apache.catalina.core.StandardService.start(StandardService.java:450)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:540)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
 at org.dom4j.io.SAXReader.read(SAXReader.java:484)
 at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
 ... 35 more
我仔细看看那些提示信息, 我找呀找呀。我猜是没有连接到数据库,但其他同事在那台机器上的系统没有问题,为什么我的会有问题呢?最主要的是我在自己的机器上运行没有问题,为什么在另一台机器上就有问题了呢?我就试着找出两机器运行环境的差别。经过N次的测试,检查类包,发现持久层我最先用是hibernate2.0版本,后来改成了hibernate3.0版本。我只修改了import可没有修改*.hbm.xml文件的dtd文件的内容。最终我把*.hbm.xml文件的
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

变为:

<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
手工把3.0改为2.0了.
这样才得以把问题解决。这问题实在是很难找呀。
在以后的开发过程中,把所有环境统一起来。在别的机器(不同环境)上多测试。
还是要多实践,把理论知识与实践联系起来。

posted on 2005-10-25 13:59 Harryson 阅读(7921) 评论(6)  编辑  收藏 所属分类: HibernateSpring

FeedBack:
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,
2006-08-16 10:40 | jun
经典,我也碰到这个问题了,多谢阿。  回复  更多评论
  
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,
2006-08-16 10:44 | Harryson
hehe,能有帮助就好,:0)  回复  更多评论
  
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,[未登录]
2007-05-30 13:49 | dongdong
我在学Hibernate碰到这个问题,多谢多谢!
不过我的是改成了<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  回复  更多评论
  
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,
2007-08-22 12:03 | tianchenyong
还有可能是 spring配置文件不统一

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

主要是以上信息  回复  更多评论
  
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,
2009-01-23 08:15 | 光辉岁月
多谢了  回复  更多评论
  
# re: spring+hibernate初始化出错,错误真是隐蔽得很,让人郁闷,,,
2012-04-17 22:12 | qiuzhiye51
太感谢了,这个问题弄了我超久  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航:
 

<2012年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(10)

随笔分类(319)

AJAX

Coffee House

CSS

Java

JavaScript

Open Source

ProjectManagement

友情Blog

最新随笔

最新评论

阅读排行榜

评论排行榜