This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "MappingException" Watch "MappingException" New topic
Author

MappingException

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
Hi,

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">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc ostgresql://192.168.1.112/work</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">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
net.sf.hibernate.cache.HashtableCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="Employee.hbm.xml"/>

</session-factory>

</hibernate-configuration>



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">
<hibernate-mapping>
<class name="pack.hib.Employee" table="emp_tab">
<id name="empNumber" column="eno" type="Integer">
<generator class="increment"/>
</id>
<property name="ename" />
<property name="salary"/>
</class>
</hibernate-mapping>


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
Bartender

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:

instead.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
jQuery in Action, 2nd edition
 
subject: MappingException