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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "MappingException" Watch "MappingException" New topic


siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68

when tried to connect to database from servlet through hibernate,I am getting the below error

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

Here Employee is my Persistence class.

Here are my configuration files.

hibernate.cfg file

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "">

<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc ostgresql://</property>;
<property name="hibernate.connection.username">infinity</property>
<property name="hibernate.connection.password">infinity</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>

<property name="show_sql">true</property>
<property name="transaction.factory_class">
<property name="hibernate.cache.provider_class">
<property name="">update</property>
<mapping resource="Employee.hbm.xml"/>



Employee.hbm file

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "">
<class name="pack.hib.Employee" table="emp_tab">
<id name="empNumber" column="eno" type="Integer">
<generator class="increment"/>
<property name="ename" />
<property name="salary"/>

i placed the above configuration files,persistent class and servlet under classes directory.

please suggest me ,what i have to do to fix this error.

Thanks in Advance,

Siva Sankar.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Without seeing the full stack trace I can say for certain, but it could be that your employee stuff if in the package pack.hib, but in your configuration you state it is in the root package. Try:


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: MappingException