org.hibernate.MappingException: invalid configuration
说明mapping文件User.hbm.xml有问题.
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-configuration", must match DOCTYPE root "hibernate-mapping".
说明文件的格式有问题.
文件头有问题
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
解决方案 »
- JAVA函数查找,引用问题
- 江湖救急:iBatis 应用 不能实例化SqlMapConfig.xml 文件.Please help me
- struts2 类型转换问题
- JDBC工具设计
- Myeclipse生成的Hibernate关联会不会极大影响性能?
- 关于对子表中没有设置外键的hbm.xml编写问题
- 一个关于编码的问题
- 有人知道在哪些网站可以下载java学习书籍,交流学习心得??
- javaweb 如何在展示的每一行数据后有 更新和删除图标 点击那个图标就会有更新和删除操作
- 两张表多对多的关系,hibernate怎么写注解
- 帮我看看,为什么validata验证呢
- 我学过J2EE,现在想学AJAX,谁能给推荐一本AJAX入门的书,先谢了.
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1354)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1288)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1274)
at ch03.hibernate.Test.main(Test.java:22)
Caused by: org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1344)
... 3 more
说明Dom4j读取hibernate.cfg.xml文件有错误,检查一下你的hibernate.cfg.xml文件的格式.
比如:
xml文件是UTF-8编码的,如果该文件通过Ultraedit编辑后,会在无BOM头的UTF-8文件中加入BOM,但是DOM4j不认这个BOM(dom4j1.3),解决的办法可以通过升级dom4j到1.6解决www.dom4j.org
什么是BOM?http://www.unicode.org/faq/utf_bom.html#22
Welcome2Hibernate
src
JRE_LIB - D:\Sun\AppServer\jdk\jre\lib\rt.jar
Hibernate3.1
mysql-connector-java-3.1.14-bin.jar - D:\mysql-connector-java-3.1.14
Hibernate 3.1 Core Libraries
antlr-2.7.5H3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
asm.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
asm-attrs.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
cglib-2.1.3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
commons-collections-2.1.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
commons-logging-1.0.4.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
dom4j-1.6.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
ehcache-1.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
hibernate3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
jaas.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
jaxen-1.1-beta-7.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
jdbc2_0-stdext.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
jta.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
log4j-1.2.11.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
xerces-2.6.2.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
xml-apis.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
src
JRE_LIB - D:\Sun\AppServer\jdk\jre\lib\rt.jar
Hibernate3.1
mysql-connector-java-3.1.14-bin.jar - D:\mysql-connector-java-3.1.14
Hibernate 3.1 Core Libraries
antlr-2.7.5H3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
asm.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
asm-attrs.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
cglib-2.1.3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
commons-collections-2.1.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
commons-logging-1.0.4.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
dom4j-1.6.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
ehcache-1.1.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
hibernate3.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
jaas.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
jaxen-1.1-beta-7.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
jdbc2_0-stdext.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
jta.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
log4j-1.2.11.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.1\lib
xerces-2.6.2.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib
xml-apis.jar - D:\MyEclipse 5.0GA\eclipse\plugins\com.genuitec.org.hibernate.eclipse_5.0.0\myeclipse-data\3.0\lib