This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MappingException class is not there in hibernate-tools.jar

 
Amrit Tiwana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hbm2Java is part of Hibernate2. If you want to use it you will have to use it with Hibernate2.
 
Amrit Tiwana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton Paul
 
Amrit Tiwana
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Along the line, make sure download the older version HSQLDB too. You should use HSQLDB 1.7.3 other than latest 1.8.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic