File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes MappingException class is not there in hibernate-tools.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "MappingException class is not there in hibernate-tools.jar" Watch "MappingException class is not there in hibernate-tools.jar" New topic
Author

MappingException class is not there in hibernate-tools.jar

Amrit Tiwana
Greenhorn

Joined: Jun 03, 2004
Posts: 24
I'm trying to generate java code using build.xml as pointed out in some article:

<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">
<hbm2java output="${source.root}">
<fileset dir="${source.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>

but I'm getting exception below.

BUILD FAILED
file:E:/hibernate/Myfiles/FirstProject/build.xml:38: 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.Task.perform(Task.java:317)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:334)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
at org.apache.tools.ant.Main.runBuild(Main.java:610)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)

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.Task.perform(Task.java:317)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:334)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
at org.apache.tools.ant.Main.runBuild(Main.java:610)
at org.apache.tools.ant.Main.start(Main.java:196)
at org.apache.tools.ant.Main.main(Main.java:235)



When I checked the hibernate-tools.jar file, there is no MappingException but is is reffered in CodeGenerator.java.

P.S. hibernate-tools.jar, hibernate3.jar, hsqldb.jar are there in classpath.

please let me know whether I'm missing something here???
Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hbm2Java is part of Hibernate2. If you want to use it you will have to use it with Hibernate2.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Amrit Tiwana
Greenhorn

Joined: Jun 03, 2004
Posts: 24
Hbm2Java is in hibernate-tools.jar not hibernate2.jar... I've downloaded hibernate-extensions2.zip also for hibernate-tools.jar, but that too doesn't contain MappingException class
Amrit Tiwana
Greenhorn

Joined: Jun 03, 2004
Posts: 24
Thanks its works...
Now I'm getting java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableException

But can you please let me know the equivalent in hibernate3???
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hibernate2 contains net.sf.hibernate.MappingException. Hibernate3 has the same class, packaged differently as org.hibernate.MappingException. Look at the API documentation for Hibernate3, you will notice that the package net.sf.hibernate does not exist. That is why hbm2java (which was written as I said for Hibernate2) cannot find net.sf.hibernate.MappingException.


Now I'm getting java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableException

But can you please let me know the equivalent in hibernate3???

There is no equivalent in Hibernate3, since that is a Commons Lang class. I strongly suggest you read the documentation on the Hibernate site, since the article you are getting directions from is out of date.
Amrit Tiwana
Greenhorn

Joined: Jun 03, 2004
Posts: 24
Thanks a ton Paul
Amrit Tiwana
Greenhorn

Joined: Jun 03, 2004
Posts: 24
Hi Paul,

Now I'm trying the same using link below:

http://www.hibernate.org/hib_docs/tools/ant/

Here there is no class named: org.hibernate.tool.ant.HibernateToolTask
in Hibernate3.jar or any other jar.

Can you help please?
Chris Su
Greenhorn

Joined: Feb 12, 2005
Posts: 8
If you're trying the sample in "Hibernate - Developer's notebook", then you'll need older version hibernate and it's extensions.

Here is what I got from OReilly's site:
"NOTE FROM AUTHOR: I have just finished a thorough update of the downloadable source examples so that they all work properly with the latest releases of Hibernate and Hypersonic.
To be specific, the code examples have been updated to work with:
Hibernate 2.1.7c
Hibernate Extensions 2.1.3
HSQLDB 1.7.3.1"

All you need to do is download correct version of Hibernate and extensions, copy all JARs from "lib" of hibernate and extensions, then re-launch ant. I just went through all the headache and finally get it build successfully.
Chris Su
Greenhorn

Joined: Feb 12, 2005
Posts: 8
Along the line, make sure download the older version HSQLDB too. You should use HSQLDB 1.7.3 other than latest 1.8.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MappingException class is not there in hibernate-tools.jar
 
Similar Threads
When trying to delete directories...
error when using xdoclet
ant unjar: ZipException when expanding
ejbdeploy throws exception
Pvcs Ant