-->
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.  [ 9 posts ] 
Author Message
 Post subject: SchemaExportTask - config file?
PostPosted: Sun Feb 15, 2004 10:35 pm 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
Hi there, I'm having trouble with the SchemaExportTask in finding its config file.

I've currently defined it as such in ANT:


<schemaexport
config="../jdeveloper/jdev/mywork/Hibernate/classes/hibernate.cfg.xml"
quiet="yes"
text="yes"
drop="no"
delimiter=";"
output="schema-export.sql"/>

I've read in previous threads that the config is a resource and so it's reference is relative to the ANT classpath. My ANT_HOME is c:\Ant, but I'm not sure if that's what was meant by the ANT classpath. (In reference to above, /jdeveloper is in c:\) Ant is complaining that it can't find the config file. May someone please help point me in the correct direction? I'd appreciate it greatly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2004 3:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A classpath is not related to a directory, Particulary, you cannot go upper than the CP root (c:\ant\..\somethingelse in your case).

Have a look at a good Java tutorial for these classpath questions.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2004 5:58 pm 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
Hm, I'm not sure what you mean by the classpath's not relating to a directory. Perhaps I misread you.

<!--Set the classpath-->
<path id="classpath">
<pathelement location="../../../../j2sdk1.4.2/lib/tools.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/rt.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/sunrsasign.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jsse.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jce.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/charsets.jar"/>
<pathelement location="../../../../ant/lib/ant.jar"/>
<pathelement location="classes"/>
<pathelement location="src"/>

<fileset dir="lib">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
</path>

These were generated by jdeveloper, and I added some in such as "classes" and "src".

Again, because of the previous mentioning of classpath, I'm confused as to what's being referred to exactly.

I've tried /hibernate.cfg.xml, hibernate.cfg.xml etc, but I would appreciate some guidance on what to look for in particular, as I've spent hours on end on this.

<schemaexport
config="${compile.outdir}/hibernate.cfg.xml"
quiet="yes"
text="yes"
drop="no"
delimiter=";"
output="schema-export.sql"/>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 16, 2004 6:00 pm 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
btw, in the above post,

<pathelement location="../../../../j2sdk1.4.2/lib/tools.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/rt.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/sunrsasign.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jsse.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jce.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/charsets.jar"/>
<pathelement location="../../../../ant/lib/ant.jar"/>


../../../../ brings me to c:\


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 2:11 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
BTW, I know about classpath's, but what I am asking in particular is why config="" won't even work when I give it the exact path of the .cfg.xml document?

PLEASE HELP!!! Am I not asking the right question? If not, please let me know, because I don't mean to be giving lack of information or begging for answers without learning. I'm here to learn, which is why I'm exploring the hibernate package in the first place. I'd greatly appreciate any assistance.

The "config=" is what's confusing to me in the <schemaexport> section. In previous posts, someone mentioned that config is treated as a resource and hence relative to ANT. May someone be so kind as to just let me know what that is referring to in particular? Is it the ant.jar that is being used to process this? Is it the build.xml file that ant is processing? I have ant.jar in several places in order to solve some previous class loader problems. Perhaps that's what's causing the confusion?


I'm running Hibernate 2.1.1.

Here's my build.xml


<?xml version = '1.0' encoding = 'windows-1252'?>

<!--Ant buildfile generated by Oracle9i JDeveloper-->
<!--Generated Feb 6, 2004 11:32:15 PM-->
<project name="HibernateTest" default="make" basedir=".">

<!--Set the JDeveloper home directory-->
<property name="jdev.home" value="C:\jdeveloper"/>

<!--Set the output directories-->
<property name="compile.outdir" value="classes"/>
<property name="javadoc.outdir" value="javadoc"/>


<!--Set the classpath-->
<path id="classpath">
<pathelement location="../../../../j2sdk1.4.2/lib/tools.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/rt.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/sunrsasign.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jsse.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/jce.jar"/>
<pathelement location="../../../../j2sdk1.4.2/jre/lib/charsets.jar"/>
<pathelement location="../../../../ant/lib/ant.jar"/>
<pathelement location="classes"/>
<pathelement location="src"/>

<fileset dir="lib">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
</path>

<!--Set the source path-->
<path id="srcpath">
<pathelement location="src"/>
</path>


<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="classpath"/>

<target name="init">
<tstamp/>
</target>

<target name="compile" depends="init">
<mkdir dir="${compile.outdir}"/>
<!--Compile Java source files-->
<javac destdir="${compile.outdir}" debug="on">
<classpath refid="classpath"/>
<src refid="srcpath"/>
<include name="com/xings/common/models/Persistent.java"/>
<include name="com/xings/journal/models/Picture.java"/>
<include name="com/xings/journal/models/Album.java"/>
<include name="com/xings/common/models/User.java"/>
</javac>
<!--Copy files to output directory-->
<!--
<copy file="src/com/xings/journal/models/Picture.hbm.xml" tofile="classes/com/xings/journal/models/Picture.hbm.xml"/>
<copy file="src/com/xings/journal/models/Album.hbm.xml" tofile="classes/com/xings/journal/models/Album.hbm.xml"/>
<copy file="src/com/xings/common/models/User.hbm.xml" tofile="classes/com/xings/common/models/User.hbm.xml"/>
-->
</target>

<target name="doc" depends="init">
<mkdir dir="${javadoc.outdir}"/>
<!--Create Javadoc-->
<javadoc sourcepathref="srcpath" classpathref="classpath" destdir="${javadoc.outdir}" version="false" author="false" additionalparam="-J-Xmx32m">
<package name="com.xings.common.models"/>
<package name="com.xings.journal.models"/>
</javadoc>
</target>

<target name="clean">
<!--Delete output directories-->
<delete dir="${compile.outdir}"/>
<delete dir="${javadoc.outdir}"/>
</target>

<target name="topdown.hbm2ddl"
description="Generates DB schema with hbm2ddl." depends="compile">


<!-- copy Hibernate mapping metadata -->
<copy todir="${compile.outdir}">
<fileset dir="src">
<include name="**/*.hbm.xml"/>
<include name="**/*.cfg.xml"/>
</fileset>
</copy>

<!-- generate and export DB schema -->


<schemaexport
config="C:\jdeveloper\jdev\mywork\Hibernate\classes\hibernate.cfg.xml"
quiet="yes"
text="yes"
drop="no"
delimiter=";"
output="schema-export.sql"/>


</target>

<target name="make" depends="compile"/>

<target name="rebuild" depends="clean,compile"/>

<target name="all" depends="compile,doc"/>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 2:15 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
MCWelch, another user who had this problem, had posted this before:

Quote:
It would appear that the "config" attribute of the <schemaexport> task does not refer to the location of the hibernate.cfg.xml file on the filesystem, but instead is looking for it within the confines of the classpath, so a value of "/hibernate.cfg.xml" means to look for the configuration file in the root of the classpath.

-Matt Welch


In my <path>, I designated "classes" as part of my classpath, and I put the hibernate.cfg.xml document in there. Yet when I do config="/hibernate.cfg.xml", it still says it can't find it. This is why I'm lost.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 4:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Quote:
In my <path>, I designated "classes" as part of my classpath, and I put the hibernate.cfg.xml document in there. Yet when I do config="/hibernate.cfg.xml", it still says it can't find it. This is why I'm lost.

I would say it should work.Can you check classes dir is really in you CP (no wrong link, etc) Set the -debug or -verbose mode to ant

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 21, 2004 2:48 am 
Newbie

Joined: Mon Feb 09, 2004 5:49 am
Posts: 17
emmanuel, thank you for your input! although no specific solution was mentioned, your "thumbs up" of sorts at least erased doubts from my mind about certain problems, allowing me to focus on other solutions.

with that focus, i finally fixed it!

i believe something strange was happening where ANT was using .jar files from c:\j2sdk1.4.2\jre\lib\ext\

I moved all those jar files from there and put them into my project's lib folder. from there on out, i had minor errors, but the classpath problem was fixed.

what a headache. something similar to this (about jars and classpaths) was eluded to in ANT's faq, however I didn't realize that it would go as far as even this hibernate.cfg/xml file situation.

THANK YOU EMMANUEL! Sometimes just having a second opinion can reinforce drive and confidence to work towards another solution. THANKS!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2004 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I had some issues with ant CL management. Ant is not the best sample for that :)

_________________
Emmanuel


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