Hibernate 3.5 抛出“org.dom4j.DocumentException:文档 http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd 第 1 行错误”
我的 Hypersistence Optimizer 代码库中有一些 Hibernate 3.5 测试,现在我收到了这个奇怪的错误:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource hbm/mapping/association/EagerFetchingManyToOneFetchJoinHbmTest.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:671)
at io.hypersistence.optimizer.util.AbstractHypersistenceOptimizerTest.newSessionFactory(AbstractHypersistenceOptimizerTest.java:108)
at io.hypersistence.optimizer.util.AbstractHypersistenceOptimizerTest.init(AbstractHypersistenceOptimizerTest.java:63)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:610)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:668)
... 25 more
Caused by: org.dom4j.DocumentException: Error on line 1 of document http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd : The markup declarations contained or pointed to by the document type declaration must be well-formed. Nested exception: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:601)
... 26 more
所有这些测试都运行良好 3 年,所以这可能是最近发生的更改。
I have some Hibernate 3.5 tests in my Hypersistence Optimizer code base, and I'm now getting this weird error:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource hbm/mapping/association/EagerFetchingManyToOneFetchJoinHbmTest.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:671)
at io.hypersistence.optimizer.util.AbstractHypersistenceOptimizerTest.newSessionFactory(AbstractHypersistenceOptimizerTest.java:108)
at io.hypersistence.optimizer.util.AbstractHypersistenceOptimizerTest.init(AbstractHypersistenceOptimizerTest.java:63)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:610)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:668)
... 25 more
Caused by: org.dom4j.DocumentException: Error on line 1 of document http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd : The markup declarations contained or pointed to by the document type declaration must be well-formed. Nested exception: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:601)
... 26 more
All these tests ran just fine for 3 years, so this may be a change that happened lately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题是由最近在
hibernate.org
网站上设置的 HTTP->HTTPS 重定向引起的:问题在于 Hibernate 3.5 无法正确处理此问题。
所以,解决方案非常简单。
将 HBM 文件开头的 DTD DOCTYPE 定义从: 更改
为:
The problem is caused by an HTTP->HTTPS redirect that was set lately on the
hibernate.org
website:The problem is that Hibernate 3.5 doesn't handle this properly.
So, the solution is very simple.
Change the DTD DOCTYPE definition at the beginning of your HBM files from:
to: