0 Replies Latest reply: Nov 28, 2008 12:42 AM by 807581 RSS

    Getting NoClassDefFoundError with ant and HibernateToolTask

    807581
      I'm trying to use the hibernate3 code generation facilities, but can't seem to get past this error. When I do "ant genJavaFromDB", I get the following error:

      BUILD FAILED
      java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

      I can see that the above class lives in lib/hibernate3.jar and that jar is in the classpath.

      Here is my build.xml:
      <project name="myproj" default="db" basedir=".">
      
         <property name="source.root" location="src"/>
         <property name="class.root" location="classes"/>
         <property name="lib.dir" location="lib"/>
         <property name="build.dir" location="build"/>
         <property name="data.dir" location="data"/>
         <property name="jdbc.driver.jar" location="${lib.dir}/mysql-connector-java-3.1.8-bin.jar"/>
      
         <path id="project.class.path">
            <pathelement location="${class.root}"/>
            <fileset dir="${lib.dir}">
                <include name="**/*.jar"/>
            </fileset>
         </path>
      
         <path id="toolslib">
            <path location="${lib.dir}/hibernate3.jar" />
            <path location="${lib.dir}/hibernate-tools.jar" />
         </path>
      
         <target name="definetasks">
            <taskdef name="hibernatetool" 
                         classname="org.hibernate.tool.ant.HibernateToolTask"
                         classpath="${lib.dir}/hibernate-tools.jar" />
         </target>
      
         <target name="genJavaFromDB" depends="definetasks">
            <hibernatetool destdir="${build.dir}/generated">
               <classpath refid="project.class.path" />
            </hibernatetool>
         </target>
      Edited by: eakle on Nov 27, 2008 10:41 PM