-->
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.  [ 5 posts ] 
Author Message
 Post subject: ant and SchemaExportTask
PostPosted: Mon Mar 03, 2008 12:11 pm 
Newbie

Joined: Thu Feb 28, 2008 8:21 pm
Posts: 10
Hello:

I am trying to get the SchemaExportTask to generate DDL for me. However, I believe there is something wrong with my Ant task. Your kind assistance is requested.


Please find below my build.xml for ANT and my hibernate.cfg.xml
I am trying to run the task schemaExportTask.

When I run --> ant schemaexport -verbose
I get the following:


Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.6 in: C:\progFiles\Java\jdk1.6.0_01\jre
Detected OS: Windows XP
parsing buildfile C:\KBD\dev\hibernate\helloworld\WORKDIR\build.xml with URI = file:/C:/KBD/dev/hibernate/helloworld/WORKDIR/build
.xml
Project base dir set to: C:\KBD\dev\hibernate\helloworld\WORKDIR
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.
[schemaexport] Running Hibernate Core SchemaExport.
[schemaexport] This is an Ant task supporting only mapping files, if you want to use annotations see http://tools.hibernate.org.
[schemaexport] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[schemaexport] log4j:WARN Please initialize the log4j system properly.

BUILD FAILED
C:\KBD\dev\hibernate\helloworld\WORKDIR\build.xml:73: Schema text failed: resource: ./build/hello/Message.hbm.xml not found
at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:151)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:96)
at org.apache.tools.ant.Main.runBuild(Main.java:683)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.hibernate.MappingNotFoundException: resource: ./build/hello/Message.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1468)
at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:194)
at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:148)
... 14 more
--- Nested Exception ---
org.hibernate.MappingNotFoundException: resource: ./build/hello/Message.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1468)
at org.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:194)
at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:148)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:96)
at org.apache.tools.ant.Main.runBuild(Main.java:683)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)


I am sure you folks who know what you are doing will see my mistake very quickly.

Thanks for your assistance.

Best Regards

KD


build.xml

<project name="Hello World" default="compile" basedir=".">

<!-- Name of project and version -->
<property name="proj.name" value="Hello World"/>
<property name="proj.shortname" value="helloworld"/>
<property name="version" value="1.0"/>

<!-- Global properties for this build -->
<property name="database.dir" value="database"/>
<property name="src.java.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<property name="build.dir" value="build"/>

<!-- Classpath declaration -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>

<!-- Useful shortcuts -->
<patternset id="meta.files">
<include name="**/*.xml"/>
<include name="**/*.properties"/>
</patternset>

<!-- Clean up -->
<target name="clean" description="Clean the build directory">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>

<!-- Compile Java source -->
<target name="compile">
<mkdir dir="${build.dir}"/>
<javac srcdir="${src.java.dir}"
destdir="${build.dir}"
classpathref="project.classpath"/>
</target>

<!-- Copy metadata to build classpath -->
<target name="copymetafiles">
<mkdir dir="${build.dir}"/>
<copy todir="${build.dir}">
<fileset dir="${src.java.dir}">
<patternset refid="meta.files"/>
</fileset>
</copy>
</target>

<!-- Run HelloWorld -->
<target name="run" depends="compile, copymetafiles"
description="Build and run HelloWorld">
<java fork="true"
classname="hello.HelloWorld"
classpathref="project.classpath">
<classpath path="${build.dir}"/>
</java>
</target>

<!-- Hibernate Tools import -->
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.classpath"/>

<schemaexport
config ="${build.dir}/hibernate.cfg.xml"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="schema-export.sql">
<fileset dir="${build.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>




<!-- Start the HSQL DB server -->
<target name="startdb" description="Run HSQL database server with clean DB">
<!-- Delete database files -->
<delete dir="${database.dir}"/>
<java classname="org.hsqldb.Server"
fork="yes"
classpathref="project.classpath"
failonerror="true">
<arg value="-database.0"/>
<arg value="file:${database.dir}/db"/>
</java>
</target>

<!-- Start the HSQL DB browser tool -->
<target name="dbmanager" description="Start HSQL DB manager">
<java
classname="org.hsqldb.util.DatabaseManagerSwing"
fork="yes"
classpathref="project.classpath"
failonerror="true">
<arg value="-url"/>
<arg value="jdbc:hsqldb:hsql://localhost/"/>
<arg value="-driver"/>
<arg value="org.hsqldb.jdbcDriver"/>
</java>
</target>

</project>

hibernate.cfg.xml


<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">org.postgres.Driver</property>
<property name="hibernate.connection.url">jdbc:postgres://localhost/benchmark_a</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">postgres</property>

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>

<!-- SQL to stdout logging
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
-->

<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<mapping resource="./build/hello/Message.hbm.xml"/>

</session-factory>
</hibernate-configuration>


Directory structure:
Volume in drive C has no label.
Volume Serial Number is 1824-0333

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR

03/03/2008 10:51 AM <DIR> .
03/03/2008 10:51 AM <DIR> ..
03/02/2008 01:01 PM <DIR> build
03/03/2008 10:50 AM 3,434 build.xml
03/01/2008 02:23 PM 3,750 build.xml.save
03/03/2008 10:48 AM 3,437 build.xml.saveA
03/01/2008 01:43 PM <DIR> database
03/03/2008 10:51 AM 0 dir.out.txt
11/10/2006 02:34 PM 450 helloworld-ddl.sql
10/19/2006 12:05 PM 3,570 HelloWorld-Native.iml
03/01/2008 02:31 PM <DIR> lib
09/03/2006 05:38 PM 1,823 license.txt
09/20/2006 02:31 PM 1,762 README.txt
03/02/2008 12:35 PM <DIR> src
8 File(s) 18,226 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\build

03/02/2008 01:01 PM <DIR> .
03/02/2008 01:01 PM <DIR> ..
03/02/2008 01:01 PM <DIR> hello
03/02/2008 05:27 PM 1,336 hibernate.cfg.xml
03/02/2008 01:01 PM 501 log4j.properties
03/02/2008 01:01 PM <DIR> persistence
2 File(s) 1,837 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\build\hello

03/02/2008 01:01 PM <DIR> .
03/02/2008 01:01 PM <DIR> ..
03/02/2008 01:01 PM 2,172 HelloWorld.class
03/02/2008 01:01 PM 692 Message.class
03/02/2008 01:01 PM 653 Message.hbm.xml
3 File(s) 3,517 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\build\persistence

03/02/2008 01:01 PM <DIR> .
03/02/2008 01:01 PM <DIR> ..
03/02/2008 01:01 PM 747 HibernateUtil.class
1 File(s) 747 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\database

03/01/2008 01:43 PM <DIR> .
03/01/2008 01:43 PM <DIR> ..
0 File(s) 0 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\lib

03/01/2008 02:31 PM <DIR> .
03/01/2008 02:31 PM <DIR> ..
08/13/2005 03:28 PM 1,034,049 ant-1.6.5.jar
08/13/2005 03:28 PM 5,667 ant-antlr-1.6.5.jar
08/13/2005 03:28 PM 74,237 ant-junit-1.6.5.jar
08/13/2005 03:28 PM 9,180 ant-launcher-1.6.5.jar
08/13/2005 03:28 PM 6,763 ant-swing-1.6.5.jar
05/05/2006 11:58 AM 443,432 antlr-2.7.6.jar
06/03/2004 11:31 AM 1,217 antlr.license.txt
06/03/2004 11:31 AM 11,358 apache.license-2.0.txt
06/03/2004 11:31 AM 2,660 apache.license.txt
03/17/2005 04:05 PM 16,777 asm-attrs.jar
03/17/2005 03:32 PM 26,360 asm.jar
01/19/2007 09:04 AM 608,376 c3p0-0.9.1.jar
06/03/2004 11:31 AM 26,430 c3p0.license.txt
12/02/2005 11:28 AM 282,338 cglib-2.1.3.jar
08/08/2004 06:35 AM 1,204,897 checkstyle-all.jar
07/22/2004 02:24 PM 142,704 cleanimports.jar
06/30/2004 04:59 AM 175,426 commons-collections-2.1.1.jar
07/04/2004 04:49 AM 38,015 commons-logging-1.0.4.jar
06/03/2004 11:31 AM 171,071 concurrent-1.3.2.jar
08/13/2005 03:28 PM 313,898 dom4j-1.6.1.jar
11/03/2006 01:05 PM 208,048 ehcache-1.2.3.jar
02/06/2008 09:31 PM 2,274,768 hibernate3.jar
06/03/2004 11:31 AM 104,359 jaas.jar
06/03/2004 11:31 AM 9,863 jaas.licence.txt
12/23/2004 09:26 PM 24,180 jacc-1_0-fr.jar
11/16/2006 01:46 PM 471,005 javassist.jar
08/16/2005 02:04 PM 226,877 jaxen-1.1-beta-7.jar
02/10/2006 09:39 PM 517,527 jboss-cache.jar
03/16/2005 12:10 AM 583,206 jboss-common.jar
03/16/2005 12:10 AM 591,568 jboss-jmx.jar
03/16/2005 12:10 AM 223,640 jboss-system.jar
12/15/2005 06:06 PM 1,611,518 jgroups-2.2.8.jar
06/03/2004 11:31 AM 8,812 jta.jar
06/03/2004 11:31 AM 9,830 jta.licence.txt
06/03/2004 11:31 AM 121,070 junit-3.8.1.jar
08/13/2005 03:28 PM 350,627 log4j-1.2.11.jar
01/19/2005 10:11 AM 114,308 oscache-2.1.jar
02/21/2008 10:58 AM 474,746 postgresql-8.3-603.jdbc4.jar
06/03/2004 11:31 AM 475,943 proxool-0.8.3.jar
06/03/2004 11:31 AM 30,602 swarmcache-1.0rc2.jar
10/24/2005 06:45 AM 142,026 syndiag2.jar
02/06/2008 09:31 PM 4,754 version.properties
11/14/2004 07:03 AM 5,762 versioncheck.jar
12/19/2004 06:14 PM 1,010,806 xerces-2.6.2.jar
06/03/2004 11:31 AM 123,705 xml-apis.jar
02/06/2008 09:34 PM 2,997 _README.txt
46 File(s) 14,317,402 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\src

03/02/2008 12:35 PM <DIR> .
03/02/2008 12:35 PM <DIR> ..
03/01/2008 01:10 PM <DIR> hello
03/01/2008 01:26 PM 1,328 hibernate.cfg.xml
10/19/2006 12:15 PM 501 log4j.properties
03/02/2008 12:41 PM <DIR> persistence
2 File(s) 1,829 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\src\hello

03/01/2008 01:10 PM <DIR> .
03/01/2008 01:10 PM <DIR> ..
09/20/2006 12:16 PM 2,844 HelloWorld.java
09/20/2006 01:16 PM 653 Message.hbm.xml
09/03/2006 05:38 PM 627 Message.java
3 File(s) 4,124 bytes

Directory of C:\KBD\dev\hibernate\helloworld\WORKDIR\src\persistence

03/02/2008 12:41 PM <DIR> .
03/02/2008 12:41 PM <DIR> ..
09/20/2006 12:10 PM 683 HibernateUtil.java
1 File(s) 683 bytes

Total Files Listed:
66 File(s) 14,348,365 bytes
26 Dir(s) 51,583,197,184 bytes free




Hibernate version: 3.2

Mapping documents:



Full stack trace of any exception that occurs:

Name and version of the database you are using:


Debug level Hibernate log excerpt:





Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 04, 2008 1:43 pm 
Newbie

Joined: Thu Feb 28, 2008 8:21 pm
Posts: 10
I re-ran with build.xml as follows:

Code:
<schemaexport
        config ="${build.dir}/hibernate.cfg.xml"
        quiet="no"
        text="no"
        drop="no"
        delimiter=";"
        output="schema-export.sql">
        <fileset dir="${build.dir}">
         <include name="**/*.hbm.xml"/>
         </fileset>
    </schemaexport>



my hibernate.cfg.xml contains:

Code:
<mapping resource="./build/hello/Message.hbm.xml"/>



error i get is:
BUILD FAILED
C:\KBD\dev\hibernate\helloworld\WORKDIR\build.xml:73: Schema text failed: resource: ./build/hello/Message.hbm.xml not found

if I change hibernate.cfg.xml to be:

Code:
<mapping resource="build/hello/Message.hbm.xml"/>


error i get is:
BUILD FAILED
C:\KBD\dev\hibernate\helloworld\WORKDIR\build.xml:73: Schema text failed: resource: build/hello/Message.hbm.xml not found

so in my simple mind it is either something with the resouce mapping or the fileset on the task in build.xml.
I do not see it.

assistance requested.

kd


Top
 Profile  
 
 Post subject: ant - schemaExportTask
PostPosted: Tue Mar 04, 2008 5:31 pm 
Newbie

Joined: Thu Feb 28, 2008 8:21 pm
Posts: 10
OK I spent a long day. Tinkering with various small changes to the build.xml file
I made changes to the "project.classpath" and to the "fileset" on the schemaexport task.

No progress.

The only thing I know for sure is that the schemaexport task is looking for the file specified in <mapping resource="hello/Message.hbm.xml"/> in hibernate.cfg.xml.
But where it is looking for it is beyond me.

I think the error is something very simple with the path.

kd


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 9:02 am 
Newbie

Joined: Tue Sep 16, 2008 1:56 am
Posts: 5
I am also facing similar problems.. Using hibernate3.jar from hibernate-tools running with jdk1.5 and tomcat 6.0.16.

I get an exception like this..

D:\Application\build.xml:111: Schema text failed: Resource: xml/hbm/User.hbm.xml not found
at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:146)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288

My build file has the following properties set.. I use similar properties for hbm2java ant task and they seem to work fine.

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

<schemaexport config="${project.src}/hibernate.cfg.xml"
quiet="no"
text="yes"
drop="no"
delimiter=";">
<fileset dir="${hibernate.hbm}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>


If some one found a workaround to this it would be great..


Top
 Profile  
 
 Post subject: I have the same problem
PostPosted: Sun Nov 16, 2008 9:26 pm 
Newbie

Joined: Sun Nov 16, 2008 8:28 pm
Posts: 14
Location: Hamburg
Hi,

I have the same problem with hibernate 3:
http://forum.hibernate.org/viewtopic.php?p=2399687

Do you find a solution?

Thx,
Nepumuk


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.