1. hibernate resolves the hibernate.cfg.xml file when the following error occurred.
Org.hibernate.HibernateException:Could not parse configuration:/hibernate.cfg.xml
At Org.hibernate.cfg.Configuration.doConfigure (configuration.java:1542)
At Org.hibernate.cfg.Configuration.configure (configuration.java:1476)
At Wenxue.db.HibernateUtils.rebuildSessionFactory (hibernateutils.java:46)
At Wenxue.db.HibernateUtils.getSession (hibernateutils.java:34)
At Wenxue.dao.generaldao.<init> (generaldao.java:15)
At Wenxue.dao.impl.cetegorydaoimpl.<init> (cetegorydaoimpl.java:7)
At Wenxue.service.impl.cetegoryserviceimpl.<init> (cetegoryserviceimpl.java:13)
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.doConfigure (configuration.java:1532)
2. Solutions
1), in the case of ensuring that the Hibernate.cfg.xml file is correct, does not include file constraints.
2), Reason: the introduction of the DTD constraint file location is incorrect.
3), I-XML file constraint file is
<! DOCTYPE hibernate-configuration Public
"-//hibernate/hibernate Configuration DTD 3.0//en"
"Http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >
4), change the constraint file to
<! DOCTYPE hibernate-configuration Public
"-//hibernate/hibernate Configuration DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >
5), view hibernate-configuration-3.0.dtd and Hibernate-mapping-3.0.dtd files
Learn about the constraint file notation for configuration and mapping.
HIBERNATE-CONFIGURATION-3.0.DTD:
<! DOCTYPE hibernate-configuration Public
"-//hibernate/hibernate Configuration DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >
HIBERNATE-MAPPING-3.0.DTD:
<! DOCTYPE hibernate-mapping Public
"-//hibernate/hibernate Mapping DTD 3.0//en"
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
Hibernate cannot parse Hibernate.cfg.xml file