-->
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: Configuration file with SchemaExportTask
PostPosted: Thu Mar 11, 2004 7:10 am 
Newbie

Joined: Sat Feb 28, 2004 9:02 am
Posts: 6
How does one use a .cfg.xml file to configure the SchemaExportTask (as opposed to a .properties file).

I tried setting a config attribute, but I keep getting

Schema text failed: path/to/file not found

But the file is there. Really, it is. It's in the same directory as the properties file it's meant to replace, and when I set the attribute properties it works.

Any idea what gives, or is it even possible to use a configuration file instead of a properties file?

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 7:24 am 
Newbie

Joined: Wed Mar 10, 2004 11:46 pm
Posts: 7
Location: china
This is my ant taget.
Code:
   <target name="hbm2ddl">
      <taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="class.path"/>
       <schemaexport properties="hibernate.properties" quiet="no" text="no" drop="no" delimiter=";" output="E:/eclipse/workspace/P_police_fire/schema-export.sql" >
      <fileset dir="${src.dest.dir}">
         <include name="**/*.hbm.xml"/>
      </fileset>
   </schemaexport>

and class.path define here.
Code:
    <path id="class.path">
      <fileset dir="E:/eclipse/lib">
         <include name="*.jar"/>
      </fileset>
     <pathelement location="${classes.dest.dir}"/>
    </path>
<property name="classes.dest.dir" value="E:/eclipse/workspace/P_police_fire/bin"/>

Wish this can give u some ideas.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 11:22 am 
Newbie

Joined: Sat Feb 28, 2004 9:02 am
Posts: 6
My build-file looks very similar. But yours has a properties file, just like mine does. I was asking how to use a configuration file (.cfg.xml extension) instead.

Anybody done this successfully, or does SchemaExportTask even allow it?

Todd


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 6:31 am 
Newbie

Joined: Sat Feb 28, 2004 9:02 am
Posts: 6
Let me try this again:

I'm using Hibernate 2.1.2. My mapping documents are irrelevant, because they work, and the code between openSession() and session.close() also works.

What I'm trying to do is have my SchemaExportTask in Ant use my config file instead of a properties file. I'd prefer to have only one, and since I can list my mappings in the config file (and, as far as I know, can't in the properties file, requiring loading them in my source code) I'd prefer a config file.

Using properties, SchemaExportTask works quite nicely, and my current workaround is to maintain both a properties file and a config file so that I can use properties with SchemaExportTask and config in my source files. Using either properties or config file, vanilla Hibernate code in classes works quite nicely. In fact, I know my config file is visible on my class path (the same one I'm giving SchemaExportTask) because

Code:
SessionFactory sf = new Configuration().configure().buildSessionFactory();


works wonderfully, and the log shows that it's using hibernate.cfg.xml as its configuration file.

However, if I try to use a config file for SchemaExportTask as shown in this excerpt of my build file

Code:
<target name="create-db" depends="copy-jars">
   <taskdef
             classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
             classpathref="project.class.path"
             name="schemaexport"/>
        <schemaexport
               config="${build.dir}/hibernate.cfg.xml"
               delimiter=";"
               drop="false"
               output="schema.sql"
               quiet="false"
               text="false"
                     <fileset dir="${build.dir}">
                           <include name="**/*.hbm.xml"/>
                      </fileset>
        </schemaexport>
</target>


I get the following exception:

create-db:
[schemaexport] 05:22:44,010 INFO Environment:462 - Hibernate 2.1.2
[schemaexport] 05:22:44,085 INFO Environment:491 - hibernate.properties not found
[schemaexport] 05:22:44,104 INFO Environment:519 - using CGLIB reflection optimizer
[schemaexport] 05:22:44,277 INFO Configuration:854 - configuring from resource: /Applications/eclipse/workspace/dupontmanual/context/WEB-INF/classes/hibernate.cfg.xml
[schemaexport] 05:22:44,331 INFO Configuration:826 - Configuration resource: /Applications/eclipse/workspace/dupontmanual/context/WEB-INF/classes/hibernate.cfg.xml
[schemaexport] 05:22:44,340 WARN Configuration:830 - /Applications/eclipse/workspace/dupontmanual/context/WEB-INF/classes/hibernate.cfg.xml not found
BUILD FAILED: /Applications/eclipse/workspace/dupontmanual/build.xml:61: Schema text failed: /Applications/eclipse/workspace/dupontmanual/context/WEB-INF/classes/hibernate.cfg.xml not found


The problem is that hibernate.cfg.xml really does exist, and right where ant appears to be looking for it. I can prove it, because when I run a JUnit test, I get:

05:25:00,433 INFO Environment:462 - Hibernate 2.1.2
05:25:00,453 INFO Environment:491 - hibernate.properties not found
05:25:00,479 INFO Environment:519 - using CGLIB reflection optimizer
05:25:00,507 INFO Configuration:854 - configuring from resource: /hibernate.cfg.xml
05:25:00,524 INFO Configuration:826 - Configuration resource: /hibernate.cfg.xml
05:25:02,443 INFO Configuration:311 - Mapping resource: org/dupontmanual/db/User.hbm.xml
05:25:03,044 INFO Binder:229 - Mapping class: org.dupontmanual.db.User -> users
05:25:03,460 INFO Configuration:311 - Mapping resource: org/dupontmanual/db/Password.hbm.xml
05:25:03,687 INFO Binder:229 - Mapping class: org.dupontmanual.db.Password -> passwords
05:25:03,699 INFO Configuration:1017 - Configured SessionFactory: null

which shows that the config file is on the class path.

Incidentally, leaving out the ${build.dir} before the path to the config file makes no difference except that the path is slightly different:

[schemaexport] 05:27:45,017 INFO Configuration:854 - configuring from resource: hibernate.cfg.xml
[schemaexport] 05:27:45,051 INFO Configuration:826 - Configuration resource: hibernate.cfg.xml
[schemaexport] 05:27:45,058 WARN Configuration:830 - hibernate.cfg.xml not found
BUILD FAILED: /Applications/eclipse/workspace/dupontmanual/build.xml:61: Schema text failed: hibernate.cfg.xml not found
Total time: 5 seconds

Now, admittedly, config is not documented as a legal attribute of SchemaExportTask, but there is a setConfig() method, and it does seem to be trying to load it.

Any ideas what gives here?

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 11:10 am 
Newbie

Joined: Wed Mar 24, 2004 11:02 am
Posts: 1
Location: Bologna, Italy
Did you get an answer? I'm having exactly the same problem.

_________________
Aldo Brucale


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.