-->
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.  [ 12 posts ] 
Author Message
 Post subject: SchemaExport can't find hibernate.cfg.xml
PostPosted: Thu Jul 08, 2004 9:48 am 
Newbie

Joined: Wed Jul 07, 2004 11:49 am
Posts: 6
Hello, hoping someone can help me with this problem that is bound to be a result of some stupid oversight of mine.

The problem is that SchemaExport can't find hibernate.cfg.xml , despite the fact that it's in the classpath. Configuration(), called from my own code with the same classpath, can find it (and the .hbm.xml files, which live in the same place). I have tried it both from ant:

Code:
  <project name="lockup" basedir="../" default="all">
[...]
  <path id="compile.classpath">
[...]
        <pathelement path="classes"/>
[...]
    <target name="schemaexport" depends="project">
        <taskdef name="schemaexport"  classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="compile.classpath"/>

        <schemaexport quiet="no" text="no" drop="no" delimiter=";" config="hibernate.cfg.xml" properties="" output="schema-export.sql">
            <fileset dir="src/java">
                <include name="**/*.hbm.xml"/>
            </fileset>
        </schemaexport>
    </target>


and on the command line:
Code:
java -cp ../classes:../lib/hibernate-tools.jar:../lib/hibernate2.jar:../lib/commons-collections.jar:../lib/commons-logging.jar:../lib/jdom.jar:../lib/commons-lang.jar:../lib/dom4j-1.4.jar:../lib/odmg-3.0.jar net.sf.hibernate.tool.hbm2ddl.SchemaExport --config="hibernate.cfg.xml"


Either way, I get
Code:
[...]
INFO: configuring from resource: hibernate.cfg.xml
Jul 8, 2004 3:39:18 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
Jul 8, 2004 3:39:18 PM net.sf.hibernate.cfg.Configuration getConfigurationInputStream
WARNING: hibernate.cfg.xml not found
Jul 8, 2004 3:39:18 PM net.sf.hibernate.tool.hbm2ddl.SchemaExport main
SEVERE: Error creating schema
net.sf.hibernate.HibernateException: hibernate.cfg.xml not found
        at net.sf.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:849)
[...]


, despite the fact that hibernate.cfg.xml exists in ../classes.

This is with Hibernate 2.1. Thanks in advance for any help you can give.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 08, 2004 9:51 am 
Newbie

Joined: Wed Jul 07, 2004 11:49 am
Posts: 6
I should add, SchemaExport works fine when I use a hibernate.properties file in ../classes instead. (But I don't want to do this as it makes the session factory producing code uglier. At the moment I have both, which is pretty silly and dangerous of course)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 11:09 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
I am having the same problem. still do not know why !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 11:13 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
the --config switch to SchemaExport is a File, that means you need to specify the full path:

<schemaexport config="${classes.dir}/hibernate.cfg.xml"
quiet="no"
text="no"/>

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 11:59 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
tried. here is my build.xml file, but still does not work
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0"?>

<project name="Canal" default="schemaexport" basedir=".">

<property name="lib.dir" value="../lib"/>
<property name="resource.dir" value="./resources"/>

<path id="classpath">
<pathelement location="${lib.dir}/hibernate2.jar"/>
<pathelement location="${lib.dir}/dom4j.jar"/>
<pathelement location="${lib.dir}/commons-logging.jar"/>
<pathelement location="${lib.dir}/commons-collections.jar"/>
<pathelement location="${lib.dir}/hibernate-2.1.1/odmg.jar"/>
<pathelement location="${lib.dir}/"/>
<pathelement location="../classes"/>
</path>

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

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

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 12:00 pm 
Newbie

Joined: Wed Jul 07, 2004 11:49 am
Posts: 6
Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 12:02 pm 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
my folder structure is:
/src/build.xml
/src/resources/hibernate.cfg.xml


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 12:09 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
@lixin_chu if using eclipse you should try to define resource.dir like
<property name="resource.dir" value="${basedir}/src/resources"/>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 12:13 pm 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
No, I am using command promopt at this moment.

If I change "config=...." to:
properties="${resource.dir}/hibernate.properties"

everything works.

a side note, text="yes" not "no" otherwise I can only get an empty .sql file !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 13, 2004 12:31 pm 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
If you put the cfg.xml into the lib dir and use the config=${lib.dir}/hibernate.cfg.xml this also doesn't work ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 7:22 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
tried. It does not work.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 8:31 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
Sounds to me like a problem with the relativ paths you are using. Ensure that they point to the right directories, or as Christian mentioned use a full path to the config file that should do the job not a good solution but a working one.

_________________
regards

Olaf

vote if it helped


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