hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:

Posted runmove

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:相关的知识,希望对你有一定的参考价值。

所报异常:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory‘ defined in class path resource [spring/applicationContext-db.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from file C:\apache-tomcat-8.0.36\webapps\crm-zhengshiban\WEB-INF\classes\com\ljr\crm\domain\CrmStudent.hbm.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1834)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from file C:\apache-tomcat-8.0.36\webapps\crm-zhengshiban\WEB-INF\classes\com\ljr\crm\domain\CrmStudent.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:406)
at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:764)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:710)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 25 more
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.dom4j.io.SAXReader.read(SAXReader.java:264)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:392)
... 30 more

 

原因:1.*.hbm.xml  或者 hibernate.cfg.xml 文件头部的 dtd导入url出现错误。

             可能的错误形式:

           <!DOCTYPE hibernate-mapping PUBLIC
                  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                 "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

解决方案:

             找到 hibernate3.jar ,分别打开jar包内的hibernate-mapping-3.0.dtd  和 hibernate-configuration-3.0.dtd 文件,比较自己

           所填写的<!DOCTYPE ....> 是不是跟这两个文件里的<!DOCTYPE ....> 分别对应正确。用文件里面的<!DOCTYPE ....>即可解决

            问题!(报此异常的 一种解决办法,我测试正确!)

           正确形式:

           *.hbm.xml中 的为:<!DOCTYPE hibernate-mapping PUBLIC
                                              "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                              "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

            hiberante.cfg.xml的为:<!DOCTYPE hibernate-configuration PUBLIC
                                                      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                                      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

 

 

修改前的配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

修改后

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">






















































以上是关于hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:的主要内容,如果未能解决你的问题,请参考以下文章

SSH框架整合配置所需JAR包(SSH整合)

JAVA内存泄露分析及解决

spring整合hibernate的事务一直错误

Hibernate三种连接池对比

为啥 Hibernate 将模式名称添加到 Hsql 函数?

JMeter测试,提高Tomca性能,链接池