-->
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.  [ 13 posts ] 
Author Message
 Post subject: middlegen r.5 classdefnotfound err.
PostPosted: Thu Aug 12, 2004 2:50 am 
Newbie

Joined: Thu Aug 12, 2004 2:43 am
Posts: 2
Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

Debug level Hibernate log excerpt:

after ant in the directory of middlegen i get related hbm.xml s then i use ant hbm2java but i get error


C:\Documents and Settings\pte\Desktop\Middlegen-Hibernate-r5\build.xml:219: Caus
ed 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: 3 seconds
C:\Documents and Settings\pte\Desktop\Middlegen-Hibernate-r5>



I add hibernate-tools and jdom jars to middle-gen lib dir after unzip middlegen.so they dont lead problem i guess what cause of this error?


Top
 Profile  
 
 Post subject: it s all about other missing needed jars
PostPosted: Thu Aug 12, 2004 3:06 am 
Newbie

Joined: Thu Aug 12, 2004 2:43 am
Posts: 2
but it takes time to find out


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 4:30 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
I think it's only a classpath problem in your hbm2java ant task...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 13, 2004 4:35 pm 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
I am getting the same error even after I put in the classpath entry for the hbm2java task. I am not using middlegen however, I am just using plain hibernate

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 3:44 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Look carefully your build.xml line 219, what is writing on this line?
I think ant is not be able to find your hibernate.jar
Show your file build.xml


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 11:51 am 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
I think you are correct in thinking that ant is not able to find the hibernate.jar in the classpath but I get this error even after putting a classpath refid line as
Code:
<classpath refid="project.class.path" />
. I did an echo on the reference and it shows the hibernate.jar in the classpath. So I am unable to understand why the hbm2java task is not able to find it in its classpath. Here is my piece of code from the build.xml

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

   <!-- 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}">
         <fileset dir="${source.root}">
            <include name="**/*.hbm.xml" />
         </fileset>
         <classpath refid="project.class.path" />
      </hbm2java>
   </target>


_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 9:46 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
And you have these lines on your build file?

<path id="project.class.path">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 11:38 am 
Beginner
Beginner

Joined: Fri Aug 13, 2004 3:07 pm
Posts: 44
Here is the definition from the build.xml

Code:
   <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>
[/code]

_________________
Thanks
Sameet


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 12:24 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: hibernate-tools.jar
PostPosted: Fri Mar 25, 2005 1:54 pm 
Newbie

Joined: Fri Mar 25, 2005 1:45 pm
Posts: 10
and where is this hibernate-tools.jar ?


Top
 Profile  
 
 Post subject: Still no luck :-( :-( :-(
PostPosted: Fri Mar 25, 2005 3:09 pm 
Newbie

Joined: Fri Mar 25, 2005 1:45 pm
Posts: 10
now that I found this jar file I was following these instructions where. I put in the same as posted earlier and also removed the jar file from ant_home/lib so it is only in the lib directory.

eclipse still prints it yellow and pretends it wouldnt find it :-( :-( :-( :-(


<path id="project.class.path">
<pathelement location="${class.root}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>


<!--<classpath refid="project.class.path" />-->


<!-- 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}">
<fileset dir="${source.root}">
<include name="**/*.hbm.xml" />
</fileset>
<classpath refid="project.class.path" />
</hbm2java>
</target>


Top
 Profile  
 
 Post subject: org.hibernate.tool.hbm2java.classic.Hbm2JavaTask
PostPosted: Fri Mar 25, 2005 3:29 pm 
Newbie

Joined: Fri Mar 25, 2005 1:45 pm
Posts: 10
Solution: org.hibernate.tool.hbm2java.classic.Hbm2JavaTask


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 25, 2005 5:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dont use that classic.hbm2javatask....it has been removed in the latest cvs version of hibernate tools.

there is a new ant task for this stuff.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.