-->
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.  [ 4 posts ] 
Author Message
 Post subject: SchemaExport: Could not configure datastore from file
PostPosted: Fri May 20, 2005 2:06 am 
Newbie

Joined: Fri May 20, 2005 1:56 am
Posts: 1
Running v3.0 (the one shipped with spring 1.2RC2), I'm attempting to generate a schema with:


<target name="schemagen">
<path id="hibernate.classpath">
<fileset dir="libraries/spring">
<include name="*.jar"/>
</fileset>
<pathelement location="src"/>
</path>
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="hibernate.classpath"/>

<schemaexport
properties="web/WEB-INF/jdbc.properties"
quiet="no"
text="yes"
drop="no"
delimiter="type=InnoDB"
output="db/hibernate_schema.sql">
<fileset dir="src">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>

My mapping file is in src/test.hbm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="letsgaggle.model.Car" table="Car">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="make" column="make" length="128" not-null="true"/>
<property name="model" column="model" length="128" not-null="true"/>
<property name="licensePlate" column="licensePlate" length="128" not-null="true"/>
<property name="year" column="year" not-null="true"/>
<property name="color" column="color" length="128" not-null="true"/>
</class>
</hibernate-mapping>

The only output is:

schemagen:
[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
/home/rich/project/build.xml:97: Schema text failed: Could not configure datastore from file: /home/rich/project/src/test.hbm.xml


Top
 Profile  
 
 Post subject: SchemaExport "cannot configure datastore from .hbm.xml
PostPosted: Mon May 30, 2005 11:30 am 
Newbie

Joined: Mon May 30, 2005 11:12 am
Posts: 4
Location: London
I am getting the same error. I am not sure what it means and would really appreciate a quick explanation. However, as I do have log4j set up properly, I get the full trace:

[schemaexport] 0 [main] INFO net.sf.hibernate.cfg.Environment - Hibernate 2.1.7
[schemaexport] 20 [main] INFO net.sf.hibernate.cfg.Environment - hibernate.properties not found
[schemaexport] 30 [main] INFO net.sf.hibernate.cfg.Environment - using CGLIB reflection optimizer
[schemaexport] 40 [main] INFO net.sf.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[schemaexport] 80 [main] INFO net.sf.hibernate.cfg.Configuration - Mapping file: ...Action.hbm.xml
[schemaexport] 261 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - trying to locate http://hibernate.sourceforge.net/hibern ... ng-1.1.dtd in classpath under net/sf/hibernate/
[schemaexport] 271 [main] DEBUG net.sf.hibernate.util.DTDEntityResolver - http://hibernate.sourceforge.net/hibern ... 1.1.dtdnot found in classpath
[schemaexport] 1633 [main] INFO net.sf.hibernate.cfg.Binder - Mapping class: com. ... .Action -> Actions
[schemaexport] 1823 [main] DEBUG net.sf.hibernate.cfg.Binder - Mapped property: id -> id, type: long
[schemaexport] 1883 [main] ERROR net.sf.hibernate.cfg.Configuration - Could not configure datastore from file: ...Action.hbm.xml
[schemaexport] java.lang.NullPointerException
[schemaexport] at net.sf.hibernate.util.StringHelper.qualify(StringHelper.java:241)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindCollection(Binder.java:510)
[schemaexport] at net.sf.hibernate.cfg.Binder$2.create(Binder.java:1435)
[schemaexport] at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:1029)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:363)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:174)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

BUILD FAILED
D:\eclipse\workspace\getonthejob\build.xml:61: Schema text failed: java.lang.NullPointerException


I am not sure what is meant by "datastore"? Is it the database? If so, I am not sure why this needs to be configured, as I have drop="no" and text="yes" attributes specified in my SchemaExport taskdef, my intention being that I only want to generate the text of the schema, and not actually upload it to the DB.

I am also vaguely worried about the warning at the top that says that it cannot find hibernate.properties, which is reasonable, as I use a hibernate.cfg.xml, which it finds OK. Is this a bug in 2.1.7 or am I doing something daft?

If any more details are required to answer this question about the datastore that cannot be found, please please let me know and I will provide them. Thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 12:09 pm 
Newbie

Joined: Mon May 30, 2005 11:12 am
Posts: 4
Location: London
OK, a little bit of progress...

Found that if the XML config file is being used, the Ant SchemaExport taskdef should have a "config" attribute pointing to it, and not "properties". The taskdef now reads the properties file correctly, but the end result is still pretty much the same:

Cannot configure datastore from input stream

What does this mean?! ;-)


Top
 Profile  
 
 Post subject: More progress!
PostPosted: Mon May 30, 2005 1:31 pm 
Newbie

Joined: Mon May 30, 2005 11:12 am
Posts: 4
Location: London
Found the problem. The reason for the failure was a mismatch in the version of the DTD used in my .hbm.xml mapping files that my XDoclet was producing and the DTD that SchemaExport was expecting. XDoclet was producing XML mapping files according to DTD 1.1 and SchemaExport was of course expecting version 2.0. After I corrected this issue, SchemaExport seems to be working properly (i.e. I get a different error, this time to do with the actual contents of the mapping files ;-). Hope this helps!

Moral of the day -- useful error messages can save time. Sadly on this occasion, the error message iven out by SchemaExport tool was utterly useless ;-)


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