Drizzy
Drizzy

Reputation: 138

Element type "hibernate-mapping" must be declared

I have around 75 .hbm.xml files in my project. Out of 75 files 4 files were using

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

and other 71 files are using

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

The project was working fine. But yesterday, when I restarted the server I found that it is not getting up and was throwing this exception.

org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 20;
Element type "hibernate-mapping" must be declared

I googled and found the solution that the 4 files is having the issue. I changed this code in those 4 .hbm.xml files

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

to this code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

and the server got up and running.

I got this issue on local, staging and live at the same time.

I am not able to find, why this happened because earlier it was working and why suddenly all machines stop working?

Is there any modification done by the hibernate team at their end?

I have to answer my senior about this issue but don't have an appropriate answer.

I am using java7, spring-core-3.0.0, spring-2.5 and spring-hibernate2 jars.

Upvotes: 4

Views: 837

Answers (2)

老衲呢
老衲呢

Reputation: 11

the url which contain 'http' replace by 'classpath', the files will work.

Upvotes: 0

St&#233;phane Millien
St&#233;phane Millien

Reputation: 3448

In mapping, I replace by:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"classpath://org/hibernate/hibernate-mapping-3.0.dtd">

In config, I replace by:

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

http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd is the good url but is very unstable since yesterday :'(

The "redirect 301" to https://hibernate.org seems causing this issue. And using directly https in xml don't work too.

Be careful, old tomcat (6 or before) does not recognize the protocol "classpath://".

Upvotes: 3

Related Questions