I just migrated us from version 3 to version 4.2.2 of Hibernate. After the migration I am getting the error "SAXParseException ... Element type hibernate-mapping must be declared." I checked my (Tomcat) WEB-INF/lib directory and Hibernate's version 4 core .jar file is there, so it's on the classpath. Before this migration, I experienced no such errors. The only change during the migration was deleting the old Hibernate .jar files and moving the "required" jars from the new Hibernate version to my project, as well as changing the DTD declaration in the .hbm.xml files.
I am aware that the Hibernate team migrated from the doctype
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
to
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
I changed my .hbm.xml files to the new DTD declaration but it does not fix the Exception described above. I looked in the hibernate core jar file and the following file is there: org/hibernate/hibernate-mapping-3.0.dtd. My project programmatically configures Hibernate through the Configuration object. In a test project using a configuration file (.cfg.xml), I conducted the same migration (from v3 to v.4.2.2) and the migration works without getting any Exceptions. (I'm not saying that the Exception is due to using programmatic configuration, but that is one possibility).
Here is the Exception:
Code:
Caused by: org.xml.sax.SAXParseException; systemId: ; lineNumber: 6; columnNumber: 20; Element type "hibernate-mapping" must be declared.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213)
at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1807)
at org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:3633)
at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1229)
at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:938)
at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
Lastly, this is a crosspost from stackoverflow.com which I apologize for. The question has been up there for quite a while with no response, but I think this is a much better forum for the question.