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

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出现错误。

             可能的错误形式:

                             "-//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 文件,比较自己

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

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

           正确形式:

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

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

 

 

修改前的配置


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

修改后


"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

转载于:https://www.cnblogs.com/move22/p/5974975.html

你可能感兴趣的:(java)