This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Author

"Could not read mapping document from file:"

jeff wisgo
Greenhorn

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(Configuration.java:269) at org.hibernate.cfg.Configuration.addDirectory(Configuration.java:582) at roverlook.HibernateSessionFactory.initialization(HibernateSessionFactory.java:89) at roverlook.HibernateSessionFactory.getCurrentSession(HibernateSessionFactory.java:33) at roverlook.VideoSessionManager.(VideoSessionManager.java:28) at roverlook.RoverlookInterface.(RoverlookInterface.java:50) at roverlook.ServiceManager.(ServiceManager.java:53) at roverlook.ControllerData.initializeData(ControllerData.java:41) at roverlook.StaticPageController.processRequest(StaticPageController.java:38) at roverlook.BasicController.doGet(BasicController.java:44) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) 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
Sebastian


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="http://www.laliluna.de" target="_blank" rel="nofollow">www.laliluna.de</a>
jeff wisgo
Greenhorn

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"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >


New XML header:


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



Thanks in advance!
Bridget Kennedy
Ranch Hand

Joined: Nov 30, 2004
Posts: 84
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:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: "Could not read mapping document from file:"
 
Similar Threads
Error in reading hibernate.cfg.xml after updating hibernate3.jar
Duplicate class/entity mapping error
Joins using Hiberntes
Duplicate collection role mapping
how to load hibernate.cfg.xml in annotation mode...