-->
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.  [ 10 posts ] 
Author Message
 Post subject: Help with SchemaExportTask
PostPosted: Mon Dec 01, 2003 9:03 pm 
Beginner
Beginner

Joined: Mon Dec 01, 2003 8:48 pm
Posts: 47
Location: Texas, United States
I have spent hours on this one, and with no luck. For some reason, the SchemaExportTask class cannot be found in the jar when I reference it. I have opened the jar and verified that the class is there and that I am referencing it properly. I get the following error when I run the ant task:

"taskdef class net.sf.hibernate.tool.hbm2ddl.SchemaExportTask cannot be found at line 34"

Funny thing is... If I reference another class in the jar, it finds it. It cannot find SchemaExportTask or SchemaUpdateTask.
Ant was able to find the TableMetadata class in the same directory for example. Weird!


Hibernate jar location: C:\tools\xdoclet\lib\hibernate2.jar

<property name="tools.dir" value="C:\tools"/>
<property name="xdoclet.dir" value="xdoclet"/>
<property name="xdoclet" value="${tools.dir}\${xdoclet.dir}"/>

<path id="compile.classpath">
<fileset dir="${xdoclet}\lib">
<include name="xdoclet-xdoclet-module-1.2b4.jar"/>
<include name="xjavadoc-1.0.jar"/>
<include name="xdoclet-hibernate-module-1.2b4.jar"/>
<include name="xdoclet.jar"/>
<include name="log4j.jar"/>
<include name="commons-logging.jar"/>
<include name="commons-collections-2.0.jar"/>
<include name="hibernate2.jar"/>
</fileset>
</path>


<target name="schemaexport">
<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<path refid="compile.classpath" />
</classpath>
</taskdef>

<schemaexport properties="hibernate.properties" quiet="no" text="yes" drop="no" delimiter=";" output="blah.sql">
<fileset dir="${src}\blah">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>


What could cause the update and export tasks not to be found? DO i have a corrupt jar file or something? Am I doing something else wrong?

I have spent three hours on this, and I cannot get past this problem.

Thanks!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 3:03 am 
Regular
Regular

Joined: Tue Sep 02, 2003 5:09 pm
Posts: 81
Location: Whitefish Montana
You might try hard coding the ${xdoclet} parameter. If this fixes your problem try setting up a build.properties file to define tools.dir and xdoclet.dir etc. The reason for this is that the taskdef is loaded before -D properties.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 11:55 am 
Beginner
Beginner

Joined: Mon Dec 01, 2003 8:48 pm
Posts: 47
Location: Texas, United States
Thanks for the reply. :-)


I changed this: <fileset dir="${xdoclet}\lib">
to this: <fileset dir="C:\tools\xdoclet\lib">

still received the same error
taskdef class net.sf.hibernate.tool.hbm2ddl.SchemaExportTask cannot be found at line 31


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 11:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/Documentation/ ... umentation

Check the workshop.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 12:43 pm 
Beginner
Beginner

Joined: Mon Dec 01, 2003 8:48 pm
Posts: 47
Location: Texas, United States
Hi Christian,

I am assuming that you wanted me to look at the build.xml file in the workshop documentation. Here's what I did...

<property name="build.dir" location="build"/>


<path id="libs">
<!--fileset dir="${xdoclet}\lib"-->
<fileset dir="C:\tools\xdoclet\lib">
<include name="xdoclet-xdoclet-module-1.2b4.jar"/>
<include name="xjavadoc-1.0.jar"/>
<include name="xdoclet-hibernate-module-1.2b4.jar"/>
<include name="xdoclet.jar"/>
<include name="log4j.jar"/>
<include name="commons-logging.jar"/>
<include name="commons-collections-2.0.jar"/>
<include name="hibernate2.jar"/>
</fileset>
</path>


Created a task def
<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath refid="libs"/>
<classpath path="${build.dir}\nathan"/>
</taskdef>


Called the task def

<target name="init">
<schemaexport config="src\nathan\hibernate.cfg.xml" quiet="yes" text="yes" drop="no" delimiter=";" output="schema-export.sql"/>
</init>


I am using a hibernate.cfg.xml file now instead of a hibernate.properties file. Here is my config file

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:oracle@some url</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">blah</property>
<property name="connection.password">blah</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<mapping resource="nathan/employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>


I am still getting the same error.

Thank you!!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I actually think you should start with the workshop example, because it is working. Try to find the difference.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 12:51 pm 
Beginner
Beginner

Joined: Mon Dec 01, 2003 8:48 pm
Posts: 47
Location: Texas, United States
I see. Good idea... I'll start with the workshop and take it from there. I appreciate your help!

Nathan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 7:53 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
hmm, did anyone have luck with this? I had ant 1.5 and got the "SchemaExport cannot be found" error also. After upgrading to ant 1.6 to see if that was the problem, the error message was more descriptive, saying:


C:\jdeveloper\jdev\mywork\Hibernate\build.xml:41: taskdef A class needed by class net.sf.hibernate.tool.hbm2ddl.SchemaExportTask cannot be found: org/apache/tools/ant/taskdefs/MatchingTask

So it can't find org.apache.tools.ant.taskdefs.MatchingTask

This, however, is in c:\ant\lib\ant.jar. So as a dirty/quick fix, I just tried to test it by throwing ant.jar into my project's lib directory, as it was already in the classpath. No luck. I then tried specifying:

<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath refid="classpath"/>
<classpath>
<pathelement path="C:\ant\lib\ant.jar"/>
</classpath>
<classpath path="${compile.outdir}"/>
</taskdef>

And I also tried calling MatchingTask also, to see if I'd get errors.

<taskdef name="matching"
classname="org.apache.tools.ant.taskdefs.MatchingTask">
<classpath refid="classpath"/>
<classpath path="${compile.outdir}"/>
</taskdef>

When I comment out the "schemaexport" section, I don't get errors, leading me to believe that it can find MatchingTask. Once I uncomment that "schemaexport" code block however, it gives me the error, saying it can't find MatchingTask! How frustrating! Any help for a beginner please? :( This is delaying me for hours and I so want to play with Hibernate! Thank you very much!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 3:39 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
I solved it!

For people with the same problem in the future:

SchemaExportTask is looking for MatchingTask, which is in ant.jar, (Jakarta Ant). The thing is that in ant, the <classpath/> tag works separately from the typical classpath that you usually need for "import"-ed files. So even though I was specifying <classpath .... = "../ant.jar"/>, ANT could find it, but the Java Import didn't. (Again, this is because ant's classpath lookup is different than the Java one.)

To fix this, throw the jar's you need into the Java Classpath that you specified on your system. For me, this was

c:\j2sdk1.4.2\jre\lib\ext

After I threw ant.jar in there, ANT no longer complained that SchemaExportTask couldn't find MatchingTask :)

hopefully this helps anyone in the future


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 3:50 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
oh, and put your c:\j2sdk\lib\tools.jar file into the same directory your threw ant.jar into! otherwise it'll complain that it can't find JAVAC

(javac.class is in tools.jar)


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