-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cant create .java from .hbm.xml using hbm2java
PostPosted: Mon Oct 04, 2004 4:27 pm 
Beginner
Beginner

Joined: Thu Jul 29, 2004 7:14 pm
Posts: 41
Hibernate version: 2.1.4

Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="dbdemo.Address" table="Address" dynamic-update="false">
<id name="id" column="ID" type="string" unsaved-value="any">
<generator class="assigned">
</generator>
</id>

<property name="city" type="string" update="true" insert="true" column="City"/>
<property name="state" type="string" update="true" insert="true" column="State"/>
<property name="zip" type="string" update="true" insert="true" column="Zip"/>

</class>

</hibernate-mapping>


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

Full stack trace of any exception that occurs:
C:\Examples\HB\NonManagedEnvironment\Meagle>ant codegen
Buildfile: build.xml

codegen:
[hbm2java] Processing 1 files.
[hbm2java] Building hibernate objects

BUILD FAILED
C:\Examples\HB\NonManagedEnvironment\Meagle\build.xml:26: Caused by:
Caused by:
java.lang.NoClassDefFoundError: org/jdom/input/SAXBuilder
at net.sf.hibernate.tool.hbm2java.CodeGenerator.main(CodeGenerator.java:
43)
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:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Hi,

I am trying to create a .java file from my .hbm.xml file. So first I create two folders lib and src in my base folder. In lib i put these jar files :
cglib-full-2.0.1.jar
commons-collections-2.1.jar
commons-logging-1.0.3.jar
dom4j-1.4.jar
ehcache-0.7.jar
hibernate2.jar
hibernate-tools.jar
jdbc2_0-stdext.jar
jta.jar
odmg-3.0.jar

In src I create Address.hbm.xml which is listed above.
In base folder I created my ant script build.xml which is :

<?xml version="1.0"?>

<project name="HB" default="codegen" basedir=".">

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

<!-- Set up the class path for compilation and execution -->
<path id="project.class.path">
<!-- Include jars in the project library directory -->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</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">

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

<hbm2java output="${source.dir}">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>

</target>

</project>

When I run ant codegen, I am getting the error message which I have mentioned above.

What am i doing wrong here? Please answer.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you don't have jdom.jar in the path ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 4:44 pm 
Beginner
Beginner

Joined: Thu Jul 29, 2004 7:14 pm
Posts: 41
i thought i just need the hibernate-tools.jar . When I copied jdom.jar and velocity-1.3.1.jar then it works.

Thanks


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