-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: NoCLassDefFoundError in hbm2java
PostPosted: Fri Aug 13, 2004 3:25 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
Hibernate version: 2.1.6

Hi,

I have a slight problem, I am aware that it might be an issue in my build file, but somehow the hbm2java task does not seem to find the MappingException class. Following is the build.xml file and then is the output of running the
Code:
codegen
target.

Code:
<?xml version="1.0"?>
<project name="Harnessing Hibernate: The Developer's Notebook"
         default="db"
         basedir=".">

   <!-- Set up properties containing important project directories -->
   <property name="source.root" value="src" />
   <property name="class.root" value="classes" />
   <property name="lib.dir" value="lib" />
   <property name="data.dir" value="data" />

   <!-- Set up the class path for compilation and execution -->
   <path id="project.class.path">
      <!-- Include our own classes, of course -->
      <pathelement location="${class.root}" />
      <!-- Include jars in the project library directory -->
      <fileset dir="${lib.dir}">
         <include name="*.jar" />
      </fileset>
   </path>

   <target name="db"
           description="Runs HSQLDB database management UI
against the database file--use when application is not running">
      <java classname="org.hsqldb.util.DatabaseManager" fork="yes">
         <classpath refid="project.class.path" />
         <arg value="-driver" />
         <arg value="org.hsqldb.jdbcDriver" />
         <arg value="-url" />
         <arg value="jdbc:hsqldb:${data.dir}/music" />
         <arg value="-user" />
         <arg value="sa" />
      </java>
   </target>

   <!-- Teach Ant how to use Hibernate's code generation tool -->
   <taskdef name="hbm2java"
            classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
            classpathref="project.class.path" />

   <!-- Generate the java code for all mapping files in our source tree -->
   <target name="codegen"
           description="Generate Java source from the O/R mapping files">
      <property name="out.path" refid="project.class.path" />
      <echo message="Classpath : \n${out.path}" />
      <hbm2java output="${source.root}">
         <classpath refid="project.class.path" />
         <fileset dir="${source.root}">
            <include name="**/*.hbm.xml" />
         </fileset>
      </hbm2java>
   </target>

   <!-- Create our runtime subdirectories and copy resources into them -->
   <target name="prepare" description="Sets up build structures">
      <mkdir dir="${class.root}" />

      <!-- Copy our property files and O/R mappings for use at runtime -->
      <copy todir="${class.root}">
         <fileset dir="${source.root}">
            <include name="**/*.properties" />
            <include name="**/*.hbm.xml" />
         </fileset>
      </copy>
   </target>

   <!-- Compile the java source of the project -->
   <target name="compile"
           depends="prepare"
           description="Compiles all Java classes">
      <javac srcdir="${source.root}"
             destdir="${class.root}"
             debug="on"
             optimize="off"
             deprecation="on">
         <classpath refid="project.class.path" />
      </javac>
   </target>

   <!-- Teach Ant how to use Hibernate's schema generation tool -->
   <taskdef name="schemaexport"
            classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
            classpathref="project.class.path" />

   <!-- Generate the schemas for all mapping files in our class tree -->
   <target name="schema"
           depends="compile"
           description="Generate DB schema from the O/R mapping files">

      <schemaexport properties="${class.root}/hibernate.properties"
                    quiet="no"
                    text="no"
                    drop="no">
         <fileset dir="${class.root}">
            <include name="**/*.hbm.xml" />
         </fileset>
      </schemaexport>
   </target>

</project>



Full stack trace of any exception that occurs:
C:\work\workspace\HibernateTest>ant codegen
Buildfile: build.xml

codegen:
[echo] Classpath : \nC:\work\workspace\HibernateTest\classes;C:\work\worksp
ace\HibernateTest\lib\ant-1.5.3.jar;C:\work\workspace\HibernateTest\lib\ant-opti
onal-1.5.3.jar;C:\work\workspace\HibernateTest\lib\c3p0-0.8.4.5.jar;C:\work\work
space\HibernateTest\lib\cglib-full-2.0.2.jar;C:\work\workspace\HibernateTest\lib
\commons-collections-2.1.1.jar;C:\work\workspace\HibernateTest\lib\commons-dbcp-
1.2.1.jar;C:\work\workspace\HibernateTest\lib\commons-lang-1.0.1.jar;C:\work\wor
kspace\HibernateTest\lib\commons-logging-1.0.4.jar;C:\work\workspace\HibernateTe
st\lib\commons-pool-1.2.jar;C:\work\workspace\HibernateTest\lib\concurrent-1.3.3
.jar;C:\work\workspace\HibernateTest\lib\connector.jar;C:\work\workspace\Hiberna
teTest\lib\dom4j-1.4.jar;C:\work\workspace\HibernateTest\lib\ehcache-0.9.jar;C:\
work\workspace\HibernateTest\lib\hibernate-tools.jar;C:\work\workspace\Hibernate
Test\lib\hibernate2.jar;C:\work\workspace\HibernateTest\lib\hsqldb.jar;C:\work\w
orkspace\HibernateTest\lib\jaas.jar;C:\work\workspace\HibernateTest\lib\jboss-ca
che.jar;C:\work\workspace\HibernateTest\lib\jboss-common.jar;C:\work\workspace\H
ibernateTest\lib\jboss-jmx.jar;C:\work\workspace\HibernateTest\lib\jboss-system.
jar;C:\work\workspace\HibernateTest\lib\jcs-1.0-dev.jar;C:\work\workspace\Hibern
ateTest\lib\jdbc2_0-stdext.jar;C:\work\workspace\HibernateTest\lib\jdom.jar;C:\w
ork\workspace\HibernateTest\lib\jgroups-2.2.3.jar;C:\work\workspace\HibernateTes
t\lib\jta.jar;C:\work\workspace\HibernateTest\lib\junit-3.8.1.jar;C:\work\worksp
ace\HibernateTest\lib\log4j-1.2.8.jar;C:\work\workspace\HibernateTest\lib\odmg-3
.0.jar;C:\work\workspace\HibernateTest\lib\oscache-2.0.jar;C:\work\workspace\Hib
ernateTest\lib\proxool-0.8.3.jar;C:\work\workspace\HibernateTest\lib\swarmcache-
1.0rc2.jar;C:\work\workspace\HibernateTest\lib\velocity-1.3.1.jar;C:\work\worksp
ace\HibernateTest\lib\xalan-2.4.0.jar;C:\work\workspace\HibernateTest\lib\xerces
-2.4.0.jar;C:\work\workspace\HibernateTest\lib\xml-apis.jar
[hbm2java] Processing 1 files.
[hbm2java] Building hibernate objects

BUILD FAILED
C:\work\workspace\HibernateTest\build.xml:46: Caused by:
Caused by:
java.lang.NoClassDefFoundError: net/sf/hibernate/MappingException
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.
java:145)
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java
:95)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:301)
at org.apache.tools.ant.Target.performTasks(Target.java:328)
at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
at org.apache.tools.ant.Main.runBuild(Main.java:632)
at org.apache.tools.ant.Main.startAnt(Main.java:183)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)

at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.processFile(Hbm2JavaTask.
java:149)
at net.sf.hibernate.tool.hbm2java.Hbm2JavaTask.execute(Hbm2JavaTask.java
:95)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:301)
at org.apache.tools.ant.Target.performTasks(Target.java:328)
at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
at org.apache.tools.ant.Main.runBuild(Main.java:632)
at org.apache.tools.ant.Main.startAnt(Main.java:183)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)


Total time: 1 second


Name and version of the database you are using: HSQLDB

Also, just so everyone knows, I am a newbie to Hibernate.

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 12:26 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
I finally figured it out. I had the hibernate-tools.jar in the locations defined by classpath ref for the taskdef
Code:
   <!-- Teach Ant how to use Hibernate's code generation tool -->
   <taskdef name="hbm2java"
            classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
            classpathref="project.class.path" />



as well as in the ant \lib directory. I believe any was setting the classpath for the task as its lib dorectory since it found the class there first. Hence eveything in the classpathref was missing. I removed the jar from the ant\lib directory and the task ran fine.

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 02, 2004 3:16 pm 
Newbie

Joined: Thu Sep 02, 2004 12:53 am
Posts: 5
Were you able to create tables following that tutorial?

Calc


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 14, 2004 1:55 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
Yes. I was. It seems to be working fine.

_________________
Thanks
Sameet


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.