I get this error when I try recreate tables in my database with hibernate.
Exception in thread "main" java.lang.NoClassDefFoundError: classes/com/golf/model/Pupil (wrong name: com/golf/model/Pupil)
The problem is, that when I recreate my tables before I execute ant, I can create the tables in database without any problem. But after I execute with ant the build.xml file, I get this error.
My build.xml file is this:
<project name="Golf" default="deploy" basedir=".">
<property name="name" value="Golf"/>
<property name="version" value="1.0"/>
<property name="project" value="Golf"/>
<property environment="env"/>
<property name="build.compiler" value="classic"/>
<property name="build.dir" value="../bin"/>
<property name="build.src" value="${build.dir}/src"/>
<property name="build.src.web" value="${build.dir}/src"/>
<property name="build.dest" value="${build.dir}/classes"/>
<property name="build.dest.web" value="${build.dir}/classes"/>
<property name="build.web" value="${build.dir}/web"/>
<property name="build.web-inf" value="${build.dir}/web/WEB-INF"/>
<property name="src.java.dir" value="../src"/>
<property name="web.src.java.dir" value="../src"/>
<property name="lib.dir" value="../lib"/>
<property name="compilelib.dir" value="../compile-lib"/>
<property name="devetc.dir" value="../etc"/>
<property name="web.dir" value="../web"/>
<property name="deliver.class" value="${deliver.dir}/WEB-INF/classes"/>
<property name="deliver.lib" value="${deliver.dir}/WEB-INF/lib"/>
<property name="distribution.dir" value="../distribution"/>
<property name="war.file.name" value="golf.war"/>
<property name="year" value="2012"/>
<property name="ant.home" value="."/>
<property name="debug" value="on"/>
<property name="optimize" value="off"/>
<property name="deprecation" value="off"/>
<target name="env">
<echo message="build.compiler = ${build.compiler}"/>
<echo message="java.class.path = ${java.class.path}"/>
<echo message="java.home = ${java.home}"/>
<echo message="user.home = ${user.home}"/>
<echo message="CATALINA.home = ${env.CATALINA_HOME}"/>
</target>
<patternset id="all.src.files">
<!-- All java files -->
<include name="**/*.java"/>
<!-- All conf files -->
<include name="**/*.xml"/>
<include name="**/*.properties"/>
<!-- All web files -->
<include name="**/*.jpg"/>
<include name="**/*.gif"/>
<include name="**/*.js"/>
<include name="**/*.jsp"/>
<include name="**/*.html"/>
</patternset>
<target name="prepare" depends="env">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dest}"/>
<mkdir dir="${build.dest.web}"/>
<mkdir dir="${build.src}"/>
<mkdir dir="${build.web}"/>
<mkdir dir="${build.web-inf}"/>
<mkdir dir="${distribution.dir}"/>
<mkdir dir="${web.src.java.dir}"/>
<mkdir dir="${build.src.web}"/>
<filter token="version" value="${version}"/>
<copy todir="${build.src}" filtering="on">
<fileset dir="${src.java.dir}" >
<patternset refid="all.src.files"/>
</fileset>
</copy>
<copy todir="${build.web}">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
<exclude name="**/*.bak"/>
</fileset>
</copy>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${build.src.web}"
destdir="${build.dest.web}"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}">
<exclude name="**/package.html"/>
<exclude name="**/overview.html"/>
<classpath>
<path>
<fileset dir="${lib.dir}"/>
<fileset dir="${compilelib.dir}"/>
</path>
</classpath>
</javac>
<copy todir="${build.web-inf}">
<fileset dir="${devetc.dir}">
<exclude name="**/*.bak"/>
</fileset>
</copy>
<copy todir="${build.dest.web}">
<fileset dir="${web.src.java.dir}">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
<exclude name="**/*.bak"/>
</fileset>
</copy>
</target>
<target name="deploy" depends="war">
<copy todir="${env.CATALINA_HOME}/webapps">
<fileset dir="${distribution.dir}">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="war" depends="compile">
<war warfile="${distribution.dir}/${war.file.name}" webxml="${devetc.dir}/web.xml">
<fileset dir="${build.web}">
<exclude name="**/lib/*.*"/>
<exclude name="**/classes/**/*.*"/>
<exclude name="**/web.xml"/>
</fileset>
<lib dir="${lib.dir}"/>
<classes dir="${build.dest.web}"/>
</war>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${distribution.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
</project>
For some reason, when I try to create the tables from Eclipse, Eclipse execute the class that is in the classes folder. That’s why the program thinks that the classes that I’m trying to map are classes/com… and not com/… If I change the build.dest and build.dest.web to {build.dir} it works perfectly.