File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate w/Tomcat error reading resource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate w/Tomcat error reading resource" Watch "Hibernate w/Tomcat error reading resource" New topic
Author

Hibernate w/Tomcat error reading resource

Levent Aksu
Greenhorn

Joined: Nov 24, 2004
Posts: 2
Hi there,
I am not new to Hibernate. I developed a full fat client/server application with it and Swing. Now I need to present some of the database with Tomcat.
I use the same mapping file, same classes etc.

Here is my hibernate.cfg.xml file:

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

<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/tima</property>
<property name="hibernate.show_sql">true</property>
<property name="dialect"> net.sf.hibernate.dialect.SybaseAnywhereDialect</property>
<mapping resource="tima.hbm.xml" />
</session-factory>
</hibernate-configuration>

net.sf.hibernate.MappingException: Error reading resource: tima.hbm.xml

both hibernate.cfg.xml and my mapping file tima.hbm.xml are under WEB-INF/classes

The problem is not that it cannot find the tima.hbm.xml file in place. Because I tried to rename it to some other thing and it is not the same error. When it cannot find the mapping file, the error becomes:

javax.servlet.ServletException: Resource: tima.hbm.xml not found

So it can find it but something ugly happens while reading it. I am sure nothing is wrong with the mapping as it is already in use by the fat client app. and it passes XML validation.

What could I be missing?
Levent
Levent Aksu
Greenhorn

Joined: Nov 24, 2004
Posts: 2
Got it by myself.
It was because it could not find my mapped classes on the classpath. I had to go into Tomcat logs to find this.
Good luck with everyone.
 
GeeCON Prague 2014
 
subject: Hibernate w/Tomcat error reading resource