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

导读:本篇文章讲解 hibernate3.0 org.dom4j.DocumentException: Connection timed out: connect Nested exception:,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

所报异常:

严重: 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”>

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/13782.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!