Exception in thread "main" org.hibernate.InvalidMappingException: Could not pars
2013-11-05 20:58
579 查看
紧接上文
导入了log4j和slf4j-lo4j的jar包之后,又提示如下异常
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/hibernate/News.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:671)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1679)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at com.hibernate.NewsManager.main(NewsManager.java:10)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:604)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:668)
... 7 more
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
at co
通过这句异常日志Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".分析,是由于映射文件头和跟节点不匹配,映射文件的头文件应该如下:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
顺便提一下,Hibernate配置文件的头文件如下:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
导入了log4j和slf4j-lo4j的jar包之后,又提示如下异常
Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/hibernate/News.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:671)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1679)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1647)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1626)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1600)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
at com.hibernate.NewsManager.main(NewsManager.java:10)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:604)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:668)
... 7 more
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
at co
通过这句异常日志Document root element "hibernate-mapping", must match DOCTYPE root "hibernate-configuration".分析,是由于映射文件头和跟节点不匹配,映射文件的头文件应该如下:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
顺便提一下,Hibernate配置文件的头文件如下:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
相关文章推荐
- 学Hibernate报:Exception in thread "main" org.hibernate.LazyInitializationException: could not initiali
- Exception in thread "main" org.hibernate.MappingException: invalid configuration
- Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
- Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.xzhl.user.model/Stu
- Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not
- Exception in thread "main" org.hibernate.MappingException: Unknown entity:
- Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transa
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: XXX
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.mao.PersonSet
- Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial valu
- 今天遇到了这样一个问题 Exception in thread "main" org.hibernate.LazyInitializationException: could not initiali
- Exception in thread "main" org.hibernate.MappingNotFoundException
- Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.fusesource
- Exception in thread "main" org.hibernate.HibernateException: Access to DialectResolutionInfo cannot
- Hibernate 5.X 版本中Exception in thread "main" org.hibernate.MappingException: Unknown entity: cn.xxx.p
- Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User
- Exception in thread "main" org.hibernate.MappingException
- Android错误:项目导入时,出现Exception in thread "main" java.lang.NoClassDef、Could not write file 。。。.classpath
- 关于hibernate中的错误:Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: tb_e
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.hibernate.domain.User