0

I’m trying to generate SQL DDL from my Hibernate annotation beans using ANT, according to hibernate tools document I have created the following Ant script:

<?xml version="1.0" encoding="UTF-8"?>
<project name="yourmarketnet" default="all" basedir=".">
<property name="build.dir" value="C:/Users/naim/Documents/NetBeansProjects/yourmarketnet/build" />
<target name="ddl_generation">
<!-- paths to required jars  -->
<path location="web/WEB-INF/lib/hibernate-annotations.jar" />
<path location="web/WEB-INF/lib/ejb3-persistence.jar" />
<path location="web/WEB-INF/lib/hibernate-entitymanager.jar" />
<path location="web/WEB-INF/lib/javaassist.jar" />
<path location="web/WEB-INF/lib/hibernate-tools.jar"/>
<path location="web/WEB-INF/lib/hibernate-entitymanager.jar" />
<path location="web/WEB-INF/lib/jboss-archive-browsing.jar" />
<path location="web/WEB-INF/lib/javaassist.jar" />

<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
    </taskdef>
    <classpath>
    <!-- path of annotation beans -->
<path location="${build.dir}/web/WEB-INF/classes/com/yourmarketnet/beans" />
</classpath>
<!-- output destination -->
<hibernatetool destdir="${build.dir}">
<!-- were the annotation beans files are located-->
<!-- list exporters here -->
<hbm2ddl
export="false"
update="false"
drop="true"
create="true"
outputfilename="myApps.ddl"
delimiter=";"
format="false"
haltonerror="true"/>
</hibernatetool>
</target>
</project>

However Im getting the following error:

taskdef class org.hibernate.tool.ant.HibernateToolTask cannot be found using the classloader AntClassLoader[]

I have checked my /lib & folder and classpath hibernate-tools is present.

2

1 Answer 1

1

In my ant scripts, I usually define a property named lib.dir with the absolute path to my lib folder, and use the tag to load all my jars, as relative paths for one reason or another have always been a problem for me. Might be worth a shot for you as well.

<property name="lib.dir" value="C:\path\to\project\WebContent\WEB-INF\lib"/>
<property name="jdk.home" value="C:\path\to\jdk" />
<path id="project.classpath">
    <fileset dir="${lib.dir}">
        <include name="*.jar"/>
    </fileset>
    <pathelement location="${jdk.home}/jre/javaws/javaws.jar"/>
    <pathelement location="${jdk.home}/jre/lib/charsets.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/dnsns.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/ldapsec.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/localedata.jar"/>
    <pathelement location="${jdk.home}/jre/lib/ext/sunjce_provider.jar"/>
    <pathelement location="${jdk.home}/jre/lib/im/indicim.jar"/>
    <pathelement location="${jdk.home}/jre/lib/im/thaiim.jar"/>
    <pathelement location="${jdk.home}/jre/lib/jce.jar"/>
    <pathelement location="${jdk.home}/jre/lib/jsse.jar"/>
    <pathelement location="${jdk.home}/jre/lib/plugin.jar"/>
    <pathelement location="${jdk.home}/jre/lib/rt.jar"/>
    <pathelement location="${jdk.home}/jre/lib/sunrsasign.jar"/>
    <pathelement location="${jdk.home}/lib/dt.jar"/>
    <pathelement location="${jdk.home}/lib/htmlconverter.jar"/>
    <pathelement location="${jdk.home}/lib/tools.jar"/>
</path>
...
// Rest of your build file
...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.