• Post Reply Bookmark Topic Watch Topic
  • New Topic

MappingException  RSS feed

siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

<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="hibernate.hbm2ddl.auto">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" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!