2015-09-21 40 views
0
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). 
log4j:WARN Please initialize the log4j system properly. 
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491) 
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1425) 
    at com.javatpoint.mypackage.StoreData.main(StoreData.java:13) 
Caused by: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect 
    at org.dom4j.io.SAXReader.read(SAXReader.java:484) 
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481) 
    ... 2 more 

爲什麼會發生這種HibernateException?運行一個簡單的Hibernate應用程序時出現HibernateException「無法解析配置:hibernate.cfg.xml」錯誤

+0

這是一個問題的可怕標題。請將其更改爲描述您問題的內容。另外,請添加更多信息,只是stacktrace沒有太大的幫助。 – Keppil

+0

ur'hibernate.cfg.xml'是不可解析的。 plz在問題中添加你的hibernate.cfg.xml文件內容。 – Bikku

+0

請上傳你的配置文件... –

回答

0

這很可能是因爲在您使用的Hibernate jar中沒有提供的hibernate.cfg.xml頂部引用DTD。

假設你不使用Hibernate 2.0版本,請檢查你的hibernate.cfg.xml你在上面:

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

而如果你正在使用XML HBM文件實體映射,然後在這些XML文件在頂部:

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