Hello,
i am using hibernate-extensions-2.1 and able to succefully generate POJO using hbm2java on command line. Now i want to run it using ant and when i run the buil.xml using ant i get following error
C:\hibernate-extensions-2.1\tools\bin>ant
Buildfile: build.xml
gen-src:
[hbm2java] Processing 1 files.
[hbm2java] Building hibernate objects
BUILD FAILED
C:\hibernate-extensions-2.1\tools\bin\build.xml:36: 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)
for reference my buil.xml file is
<?xml version="1.0"?>
<project name="Sequel System Hinbernate" default="gen-src" basedir=".">
<target name="init">
<property name="src.dir" value="." />
<property name="src.home" value="." />
<property name="name" value="EMR" />
<property name ="generated.home" value="." />
<property name="JDBC_DRIVER" value="C:" />
<property name="HIBERNATE_HOME" value="C:/hibernate-2.1" />
<property name="CORELIB" value="${HIBERNATE_HOME}/lib" />
<property name="LIB" value="C:/hibernate-extensions-2.1/tools/lib" />
<path id="project.class.path">
<pathelement location="C:/ojdbc.jar" />
<pathelement location="C:/hibernate-2.1/hibernate2.jar" />
<pathelement location="${CORELIB}/commons-logging-1.0.3.jar" />
<pathelement location="${CORELIB}/commons-collections-2.1.jar" />
<pathelement location="${CORELIB}/commons-lang-1.0.1.jar" />
<pathelement location="${CORELIB}/cglib-2.0-rc2.jar" />
<pathelement location="${CORELIB}/dom4j-1.4.jar" />
<pathelement location="${CORELIB}/odmg-3.0.jar" />
<pathelement location="${CORELIB}/xml-apis.jar" />
<pathelement location="${CORELIB}/xerces-2.4.0.jar" />
<pathelement location="${CORELIB}/xalan-2.4.0.jar" />
<pathelement location="${LIB}/jdom.jar" />
<pathelement location="${LIB}/hibernate-tools.jar" />
</path>
</target>
<target name="gen-src">
<taskdef
name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="project.class.path"
/>
<hbm2java output="${src.dir}" classpathref="project.class.path" config="C:/hibernate-extensions-2.1/tools/bin/hbm2java.xml">
<fileset dir="C:/hibernate-extensions-2.1/tools/bin">
<include name="**/com/sequelsys/emr/model/Dept.hbm.xml"/>
<include name="**/com/sequelsys/emr/model/Emp.hbm.xml"/>
</fileset>
</hbm2java>
</target>
</project>
and all the required jar on the above specified location
The Dept.hbm.xml is as follows generated using MiddleGen
<?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>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.sequelsys.emr.model.Dept"
table="DEPT"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="DEPT"
</meta>
<id
name="deptno"
type="java.lang.Integer"
column="DEPTNO"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Integer"
column="DEPTNO"
@hibernate.generator-param
name="sequence"
value="DEPT_SEQ"
</meta>
<generator class="sequence">
<param name="sequence">DEPT_SEQ</param>
</generator>
</id>
<property
name="dname"
type="java.lang.String"
column="DNAME"
length="14"
>
<meta attribute="field-description">
@hibernate.property
column="DNAME"
length="14"
</meta>
</property>
<property
name="loc"
type="java.lang.String"
column="LOC"
length="13"
>
<meta attribute="field-description">
@hibernate.property
column="LOC"
length="13"
</meta>
</property>
<!-- associations -->
<!-- bi-directional one-to-many association to Emp -->
<set
name="emps"
lazy="true"
inverse="true"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
@hibernate.collection-key
column="DEPTNO"
@hibernate.collection-one-to-many
class="com.sequelsys.emr.model.Emp"
</meta>
<key>
<column name="DEPTNO" />
</key>
<one-to-many
class="com.sequelsys.emr.model.Emp"
/>
</set>
</class>
</hibernate-mapping>
and Emp.hbm.xml is as follows also generated using MiddleGen
<?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>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.sequelsys.emr.model.Emp"
table="EMP"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="EMP"
</meta>
<id
name="empno"
type="java.lang.Integer"
column="EMPNO"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Integer"
column="EMPNO"
@hibernate.generator-param
name="sequence"
value="EMP_SEQ"
</meta>
<generator class="sequence">
<param name="sequence">EMP_SEQ</param>
</generator>
</id>
<property
name="ename"
type="java.lang.String"
column="ENAME"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="ENAME"
length="10"
</meta>
</property>
<property
name="job"
type="java.lang.String"
column="JOB"
length="9"
>
<meta attribute="field-description">
@hibernate.property
column="JOB"
length="9"
</meta>
</property>
<property
name="mgr"
type="java.lang.Integer"
column="MGR"
length="4"
>
<meta attribute="field-description">
@hibernate.property
column="MGR"
length="4"
</meta>
</property>
<property
name="hiredate"
type="java.sql.Timestamp"
column="HIREDATE"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="HIREDATE"
length="7"
</meta>
</property>
<property
name="sal"
type="java.math.BigDecimal"
column="SAL"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="SAL"
length="7"
</meta>
</property>
<property
name="comm"
type="java.math.BigDecimal"
column="COMM"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="COMM"
length="7"
</meta>
</property>
<!-- associations -->
<!-- bi-directional many-to-one association to Dept -->
<many-to-one
name="dept"
class="com.sequelsys.emr.model.Dept"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="DEPTNO"
</meta>
<column name="DEPTNO" />
</many-to-one>
</class>
</hibernate-mapping>
Please help me asap.
Regards,
Shoaib Akhtar