-->
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: Unable to successfully run hbm2ddl.SchemaExport tool
PostPosted: Thu Oct 20, 2005 8:30 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
I am using Hibernate release 3.0.5

I have configured my setup following Chapter 1 of the reference-manual carefully, up to the point where that reference-manual suggests using the hbm2ddl tool. I want to use it. I have tried for two days now to get something to work.

When I run this I get a warning that the process cannot find the hibernate.properties file ... and that it cannot find the hibernate.cfg.xml file (file not found) then, of course, the process fatals.

To make it easier to modify, run, modify, run ... I have created a shell script which i modify, write to disk, run. I am using linux. I have tried providing full path names for the properties file and cfg.xml and relative path names ... I have tried moving the file to current directory, etc. Nothing seems to work. I will appreciate any guidance to repair whatever stupidity I have committed. Thanks!

Following is the script:

java \
-cp code/suncertify/web/WEB-INF/lib/hibernate3.jar:\
code/suncertify/web/WEB-INF/lib/commons-logging-1.0.4.jar:\
code/suncertify/web/WEB-INF/lib/dom4j-1.6.jar:\
code/suncertify/web/WEB-INF/lib/commons-collections-2.1.1.jar\
org.hibernate.tool.hbm2ddl.SchemaExport \
--text \
--config=code/suncertify/web/WEB-INF/hibernate.cfg.xml \
--properties=hibernate.properties \
code/suncertify/client/ServiceProvider.hbm.xml

By the way, while working with this I have the pdf of the reference-manual up in another window, set to Chapter 21, the chapter on how to use this tool.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 9:13 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
if hibernate.cfg.xml is in the root of the classpath, all will work. for example, in a webapp, this would be under WEB-INF/classes or the root of a jar under WEB-INF/lib .


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 8:55 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
Well, I had hibernate.cfg.xml under WEB-INF. I moved it to WEB-INF/classes. Didn't seem to make any difference.

This is what I get as a responce from hbm2ddl.SchemaExport:

Oct 21, 2005 8:41:29 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0.5
Oct 21, 2005 8:41:29 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Oct 21, 2005 8:41:29 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Oct 21, 2005 8:41:29 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Oct 21, 2005 8:41:30 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: code/suncertify/web/WEB-INF/classes/hibernate.cfg.xml
Oct 21, 2005 8:41:30 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: code/suncertify/web/WEB-INF/classes/hibernate.cfg.xml
Oct 21, 2005 8:41:30 PM org.hibernate.cfg.Configuration getConfigurationInputStream
WARNING: code/suncertify/web/WEB-INF/classes/hibernate.cfg.xml not found
Oct 21, 2005 8:41:30 PM org.hibernate.tool.hbm2ddl.SchemaExport main
SEVERE: Error creating schema
org.hibernate.HibernateException: code/suncertify/web/WEB-INF/classes/hibernate.cfg.xml not found
... [ plus more stuff ]

The file "code/suncertify/web/WEB-INF/classes/hibernate.cfg.xml" IS exactly at that place! ... relative to where I am running the script. What to try next?

Now, I have a question: are we supposed to be running this against the deployed codeset or the dev codeset. I am not running this against the deployed codeset, but against the development environment. Of course, the compiled code is also available there but I do not reference it at all while trying to run SchemaExport.

I see you have 50 points. I know you are a busy fellow. I appreciate the help you are giving me. Thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 9:02 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
The webapp stuff was just an example. The basic principle still applies whether you are just running a unit test or a some other standalone app.

This however only applied if you are calling org.hibernate.cfg.Configuration.configure() w/ no arguments. If you are still having problems, try going about the problem from the other direction ... Configuration conf = new Configuration().configure("/some/other/place/under/the/classpath");


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 10:40 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
HALLELUJAH!!

It works!

I removed the "config={location of the hibernate.cfg.xml file}" as an option to the SchmeaExport command. I had to add another jar file to the classpath (jta.jar - required to run not in the context of an app server or tomcat). I added back the "properties=./hibernate.properties" option to the command. and, .. whallah, it worked!

Dennis, you have done a good night's work. I thank you.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.