org.hibernate.InvalidMappingException: Could not parse mapping document from resource *.hbm.xml

放肆的年华 提交于 2019-12-04 11:13:33

The error Could not parse mapping document is about your xml files not being well-formed. When this error comes up, we'd better double check our xml files to see if they are really OK (all tags are properly closed and so on).


In your case, as the message states, your Student.hbm.xml file is the problem. You have some tags that do not belong:

<property name="firstName" type="string" column="FirstName" />
</property> <------------------------------------------------------ remove this
<property name="lastName" type="string" column="LastName"/>
</property> <------------------------------------------------------ remove this
<property name="program" type="string" column="Program"/>
</property> <------------------------------------------------------ remove this

Those closing </property> tags aren't closing no one, as the <property tags above them are self-closed (notice the />).

Try to change hibernate mapping DTD. My problem solves after changing http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd to http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd

May Be This problem because of Not matching with The variable names used in bean class.

For eg. Then Your variable names should be FirstName.

In my case was just a comment at the beggining of xml. If someone have a comment like just remove it and maybe will work.

Please remove <?xml version="1.0"?> from your mapping and config file.It will solve your problem

you might have configured multiple times of mapping tag for same entity/persistence.

My problem solves after changing http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd to http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd. The issue could caused by timeout when access to remote DTD file.

I would download the hibernate-mapping-3.0.dtd and make it available locally.

SANTOSH BIRADAR

You just close your property like

<property name="firstName" type="string" column="FirstName" />

or

<property name="firstName" type="string" column="FirstName"></property>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!