-->
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.  [ 7 posts ] 
Author Message
 Post subject: SchemaExportTask
PostPosted: Sun Feb 15, 2004 12:04 pm 
Newbie

Joined: Fri Feb 13, 2004 7:57 pm
Posts: 9
Location: Montreal, Canada
Hi,

Am using Hibernate 2.1, JDK 1.4.2, and running the ant task SchemaExportTask, get the following and the ddl is not being generated.

Buildfile: D:\eclipseProjs\Hibern8Xmpl\build\build_1.xml
db-schema:
[schemaexport] log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.
BUILD FAILED: file:D:/eclipseProjs/Hibern8Xmpl/build/build_1.xml:99: Schema text failed: org.dom4j.DocumentException: Error on line 1 of document : Document root element is missing. Nested exception: Document root element is missing.
Total time: 931 milliseconds

Appreciate any leads,
Thanks


Top
 Profile  
 
 Post subject: SchemaExportTask
PostPosted: Sun Feb 15, 2004 1:28 pm 
Newbie

Joined: Fri Feb 13, 2004 7:57 pm
Posts: 9
Location: Montreal, Canada
....the ant code used, reference to the previous post

<target name="db-schema">

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

<schemaexport
properties="${proj.bin}/hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="${proj.build.dir}/example_schema.sql">

<fileset dir="${proj.bin}">
<include name="*.hbm.xml"/>
<include name="*.class"/>
<include name="*/*.zip" />
<include name="*/*.properties" />
</fileset>

</schemaexport>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2004 1:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
RTFM. You should only include the hbm.xml files in the fileset.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2004 2:11 pm 
Newbie

Joined: Fri Feb 13, 2004 7:57 pm
Posts: 9
Location: Montreal, Canada
Thanks for the response,

Excluding
<include name="*.class"/>

from the fileset gives the following:

Buildfile: D:\eclipseProjs\Hibern8Xmpl\build\build_1.xml
db-schema:

[schemaexport] log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.
BUILD FAILED: file:D:/eclipseProjs/Hibern8Xmpl/build/build_1.xml:99: Schema text failed: net.sf.hibernate.MappingException: persistent class [dbdemo.Address] not found
Total time: 1 second

I've checked that all the required libraries are in
classpathref="project.class.path", essentially the /hibernate/lib directory

and the log4j.properties and hibernate.properties files are in the same directory as *.class and *.hbm.cml


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 15, 2004 6:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You should have the mapped classes in your classpath (the one that load the SchemaExport task I guess).

_________________
Emmanuel


Top
 Profile  
 
 Post subject: SchemaExportTask
PostPosted: Tue Feb 17, 2004 10:57 pm 
Newbie

Joined: Fri Feb 13, 2004 7:57 pm
Posts: 9
Location: Montreal, Canada
Thanks for all your responses, my problem was setting up the required classpath as was pointed out by 'emmanuel'. From another post it was gleaned that SchemaExportTask expects the persistent classes in a jar file.

The following seems to work :), would appreciate any comments for improvements

<!-- ================================================================== -->
<!-- Export Database Schema from mapping files -->
<!-- ================================================================== -->

<target name="setup_schemaExport_classpath">
<!-- persistent classes are expected to be in a *.jar file -->
<!-- with the proper package heirarchy -->
<echo message="-- creating persistentClasses.jar file --" />
<jar jarfile="${proj.build.dir}\persistentClasses.jar"
basedir="${proj.bin.dir}"
includes="**/*.class"/>
<echo message="" />

<!-- create the class path for the SchemaExportTask -->
<echo message="- creating schemaExportTask classpath -" />

<path id="schemaExport.class.path">
<!--path for the hibernate jar/-->
<pathelement path="${hibernate.jar}"/>
<!--path for the hibernate lib jars/-->
<fileset dir="${hibernate.lib}">
<include name="**.jar"/>
</fileset>
<!--path for the persistentClasses.jar/-->
<fileset dir="${proj.build.dir}">
<include name="**.jar" />
</fileset>
</path>
</target>

<target name="generate_db_schema" depends="setup_schemaExport_classpath">

<echo message="------- running db_schema --------" />
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="schemaExport.class.path"/>

<schemaexport
properties="${proj.bin.pkg}/hibernate.properties"
quiet="no"
text="yes"
drop="no"
delimiter=";"
output="${proj.build.dir}/example_schema.sql">
<fileset dir="${proj.bin.pkg}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 6:47 am 
Newbie

Joined: Fri Feb 13, 2004 7:57 pm
Posts: 9
Location: Montreal, Canada
The above does not export the schema to the database, to enable the export the following (higlighted) is required:

<target name="setup_schemaExport_classpath">
<!-- persistent classes are expected to be in a *.jar file -->
<!-- with the proper package heirarchy -->
<echo message="-- creating persistentClasses.jar file --" />
<jar jarfile="${proj.build.dir}\persistentClasses.jar"
basedir="${proj.bin.dir}"
includes="**/*.class"/>

<echo message="" />

<!-- create the class path for the SchemaExportTask -->
<echo message="- creating schemaExportTask classpath -" />

<path id="schemaExport.class.path">
<!--path for the hibernate jar/-->
<pathelement path="${hibern8.jar.file}"/>
<!--path for the hibernate lib jars/-->
<fileset dir="${hibern8.lib.dir}">
<include name="**.jar"/>
</fileset>
<!--path for the persistentClasses.jar/-->
<fileset dir="${proj.build.dir}">
<include name="**.jar" />
</fileset>
<!--path for the database jar/-->
<fileset dir="${db2.jars.dir}">
<include name="**/*.jar"/>
</fileset>

</path>
</target>

<target name="generate_db_schema" depends="setup_schemaExport_classpath">

<echo message="------- running db_schema --------" />
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="schemaExport.class.path"/>

<schemaexport
properties="${bin.pkg.dir}/hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="${proj.build.dir}/example_schema.sql">
<fileset dir="${bin.pkg.dir}">
<include name="**/*.hbm.xml"/>
</fileset>

</schemaexport>


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