The moose likes Object Relational Mapping and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark ""Could not read mapping document from file:"" Watch ""Could not read mapping document from file:"" New topic

"Could not read mapping document from file:"

jeff wisgo

Joined: Apr 20, 2004
Posts: 15
I have hibernate working perfectly on my development server, but when I zip up all the files (including tomcat, java, all JSP, class files, and JAR files) and reproduce this tree on another system with the same newly-installed OS (Redhat Enterprise), Hibernate is failing immediately with the following exception:

System Error: org.hibernate.MappingException: Could not read mapping document from file: /enerlook/jakarta-tomcat/webapps/roverlook/WEB-INF/classes/roverlook/Media.hbm.xml at org.hibernate.cfg.Configuration.addFile( at org.hibernate.cfg.Configuration.addDirectory( at roverlook.HibernateSessionFactory.initialization( at roverlook.HibernateSessionFactory.getCurrentSession( at roverlook.VideoSessionManager.( at roverlook.RoverlookInterface.( at roverlook.ServiceManager.( at roverlook.ControllerData.initializeData( at roverlook.StaticPageController.processRequest( at roverlook.BasicController.doGet( at javax.servlet.http.HttpServlet.service( at

The 'Media.hbm.xml' file is there with the same permissions, checksum, and size as the one on the existing server. There must be some difference between the systems causing this, but I can't fathom what it is. Any ideas?
Sebastian Hennebrueder
Ranch Hand

Joined: Sep 09, 2004
Posts: 49
Just an idea, did you verify that it is not a class issue. This is quite common especially with JBoss application server.
Which Server, Java, Hibernate Version do you use?

Best Regards

Things get always more complicated as expected.<br />Author of eBook Hibernate 3 Developer Guide by example<br />Tutorials about Hibernate, EJB, Struts, JSF <a href="" target="_blank" rel="nofollow"></a>
jeff wisgo

Joined: Apr 20, 2004
Posts: 15
I found my problem, but I haven't solved it completely. The problem was that the DTD in my .hbm.xml file was pointing to an external source, but I didnt have my name server configured. Unfortunately, I would like this server to work without needing external internet access, so I have tried to compy the .dtd file to my local file system in the same directory as my .hbm.xml files and changed the path to "./(filename)", but it still is unable to find the file.

As a follup question, does anyone know where my default directory would be in this case?

Old XML header:

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"" >

New XML header:

<!DOCTYPE hibernate-mapping SYSTEM
"./hibernate-mapping-2.0.dtd" >

Thanks in advance!
Bridget Kennedy
Ranch Hand

Joined: Nov 30, 2004
Posts: 86
I just tackled this same issue. I put the dtd in the current working directory and referenced it in the hbm.xml files as so:

Note that I am using Hibernate 3.0. Your file will be the 2.0 dtd - unless you have upgraded to Hibernate 3.0, in which case you have another problem: mismatched Hibernate version and dtd. :roll:
I agree. Here's the link:
subject: "Could not read mapping document from file:"
It's not a secret anymore!