hi
your hibernate.cfg.xml has to be in the class path, if you're running tomcat that's ${project_dir}/WEB-INF/classes
so i'm not sure where you have it, but you need to get it in there one way or another. the problem is, eclipse doesn't show this folder, and everytime you clean your project the classes dir gets erased. so you'll be copying that file over a lot.
the solution i came up with was to make a sepearte conf dir, and put all my config files in there. then use an ant build script to copy all those files to classes everytime i build.
here's my build.xml, modify to suit your needs (don't expect it to run without going through it first). in eclipse there's a number of ways to run it. right click it -> run as -> ant build. or you can go project -> properties -> builders and set it up in there, however i find it to be a pain this way as you may just want to let eclipse compile your files automatically, and just run this when you change some hibernate related stuff.
Code:
<!-- Ant build file for a tomcat project with hibernate.
Uses xdoclet to generate the mapping files and schema export to
create the tables.
Set the project name and the project.name in the next two lines. -->
<project name="dosimetry" default="build">
<property name="project" value="dosimetry" />
<property name="conf.dir" value="conf" />
<property name="web-inf.dir" value="WEB-INF" />
<property name="classes.dir" value="${web-inf.dir}/classes" />
<property name="lib.dir" value="${web-inf.dir}/lib" />
<property name="src.dir" value="${web-inf.dir}/src" />
<!-- value="/usr/local/tomcat/common/lib" /> -->
<property name="tomcat.lib.dir" value="c:/tomcat/common/lib" />
<path id="project.classpath">
<pathelement location="${classes.dir}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${tomcat.lib.dir}/servlet-api.jar" />
<pathelement location="${tomcat.lib.dir}/jasper-runtime.jar" />
<pathelement location="${tomcat.lib.dir}/jsp-api.jar" />
<pathelement location="${basedir}/../Hibernate/classes" />
<pathelement location="${basedir}/../DisplayTag/classes" />
</path>
<target name="configure.eclipse" if="eclipse.running">
<property name="build.compiler"
value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<echo message="Configuring compiler for Eclipse..."/>
</target>
<!-- clean the project's output dir and
delete the schema export file -->
<target name="clean">
<delete>
<fileset dir="${classes.dir}">
<exclude name="log4j.properties" />
<include name="**/*" />
</fileset>
</delete>
</target>
<!-- compile the project -->
<target name="compile">
<antcall target="configure.eclipse" />
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
classpathref="project.classpath" />
</target>
<!-- clean, compile -->
<target name="copyClasses" depends="compile">
<copy todir="${classes.dir}" preservelastmodified="true">
<fileset dir="${src.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!-- compile, and use xdoclet to generate the .hbm.xml files -->
<target name="generate-hbm" depends="compile">
<taskdef name="hibernatedoclet"
classname="xdoclet.modules.hibernate.HibernateDocletTask"
classpathref="project.classpath" />
<property file="${conf.dir}/hibernate.properties" />
<hibernatedoclet destdir="${classes.dir}"
verbose="true">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<hibernate version="3.0" />
<hibernatecfg dialect="${hibernate.dialect}"
jdbcUrl="${hibernate.connection.url}"
driver="${hibernate.connection.driver_class}"
userName="${hibernate.connection.username}"
password="${hibernate.connection.password}"
showSql="true"
version="3.0" />
</hibernatedoclet>
</target>
<!-- copy all those files in conf to class dir -->
<target name="copyConf">
<copy todir="${classes.dir}" preservelastmodified="false">
<fileset dir="${conf.dir}" />
</copy>
</target>
<!-- copy any dependecies (other projects) over -->
<target name="copyDep">
<copy todir="${classes.dir}" preservelastmodified="true">
<fileset dir="${basedir}/../Hibernate/classes" />
<fileset dir="${basedir}/../DisplayTag/classes" />
</copy>
</target>
<!-- generate the mapping documents and use schema export to create the tables -->
<target name="schema-export" depends="generate-hbm">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.classpath" />
<schemaexport quiet="no"
output="${conf.dir}/schema-export.sql"
properties="${conf.dir}/hibernate.properties">
<fileset dir="${classes.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
<!-- clean, compile, build, generate-hbm, schema-export -->
<target name="build"
depends="clean, compile, copyClasses,
generate-hbm, copyConf, copyDep" />
</project>
hope that helps