Our project use's Hibernate's programmatic Configuration
to set up our SessionFactory and such. I just migrated us from version 3 to version 4 of Hibernate. Now I am getting the error "Element type "hibernate-mapping" must be declared." which it says is a SaxParseException. That's great and all, but I checked my WEB-INF/lib directory and Hibernate's version 4 core .jar file is there, so it's on the classpath.
At first I thought it's because Hibernate team migrated from
<!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">
But that doesn't fix the error. What is going on? In a separate project where I am using the XML configuration file for Hibernate, I did the same migration, and it went fine. Please note that on my environment classpath must be used, the DTD cannot be downloaded from the internet or anything like that. It shouldn't be anyway.
edit: here's the exception as requested:
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)
<!DOCTYPE hibernate-mapping SYSTEM "classpath://org/hibernate/hibernate-mapping-3.0.dtd">
– Christogram<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.example.entity.Person" table="TBPerson"> <id column="idPerson" name="id" type="long"> <generator class="identity"/> </id> <property column="Name" name="name" type="string"/> </class> </hibernate-mapping>
. – Babexerces.jar
was messing it all up. I wouldn't feel "worthy" of the bounty because while my comment helped to work around it, we didn't really discover the root cause. – Babe