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: SchemaExportTask Ant: Could not parse mapping document
PostPosted: Fri Mar 09, 2007 12:17 pm 
Newbie

Joined: Fri Sep 23, 2005 6:44 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Bonjour,

J'essaye de générer du DDL avec ShemaExport en le lançant avec la tache Ant ShemaExportTask de HibernateTool. La tache se lance, lit le fichier de configuration et elle échoue en tentant de parser le premier fichier de mapping.

Message d'erreur:
Schema text failed: Could not parse mapping document


Le hibernate.cfg.xml fait référence à 2 fichiers de mapping, si j'inverse leur ordre dans Le hibernate.cfg.xml l'erreur est exactement la même mais pour l'autre fichier. SchemaExport échoue donc sur le premier fichier de mapping rencontré.

J'ai une console configuration définit avec le pluggin eclipse Hibernate Tools 3.2 beta9a, basée sur les mêmes fichiers de mapping qui se comporte normalement.

Je ne comprends pas ce qui se passe.


Hibernate version:
3.2.2
Hibernate Tools 3.2 beta9a,
Mapping documents:


hibernate.cfg.xml:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="hibernate.connection.url">
jdbc:hsqldb:hsql://localhost/db1
</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.default_schema">PUBLIC</property>
<property name="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<mapping resource="sca/hibernate1/entities/Person.hbm.xml" />
<mapping resource="sca/hibernate1/entities/Event.hbm.xml" />
</session-factory>
</hibernate-configuration>

Person.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="sca.hibernate1.entities">
<class name="Person" table="H_PERSON" >
<id name="id" column="ID">
<generator class="increment" />
</id>
<property name="name" column="LASTNAME"/>
<set name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<many-to-many class="Event" column="EVENT_ID"/>
</set>
</class>
</hibernate-mapping>

Event.hbm.xml:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="sca.hibernate1.entities">
<class name="Event" table="EVENTS">
<id name="id" column="ID">
<generator class="increment" />
</id>
<property name="title"/>
<property name="date" type="timestamp" column="EVENT_DATE"/>
</class>
</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():

Ant buil file:


<project name="build mv" basedir=".">

<property name="src" location="src" />
<property name="bin" location="bin" />
<property name="lib.home" location="D:/lib/" />

<path id="classpath">
<fileset dir="${lib.home}\hibernate-3.2\" includes="**/*.jar" />
<pathelement path="${src}" />
</path>

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

<schemaExport output="schema-export.sql" config="${src}\hibernate.cfg.xml" text="yes" quiet="no" drop="no">



<fileset dir="${src}">
<include name="**/*.hbm.xml,**/*.cfg.xml" />
</fileset>
</schemaExport>

</target>
</project>




Full stack trace of any exception that occurs:
console stack:

Buildfile: D:\Callisto\workspaces\default\hibernate1\build-mv.xml
schemaExport:
[schemaExport] 17:00:50,484 INFO Environment:509 - Hibernate 3.2.2
[schemaExport] 17:00:50,500 INFO Environment:542 - hibernate.properties not found
[schemaExport] 17:00:50,500 INFO Environment:676 - Bytecode provider name : cglib
[schemaExport] 17:00:50,500 INFO Environment:593 - using JDK 1.4 java.sql.Timestamp handling
[schemaExport] 17:00:50,562 INFO Configuration:1460 - configuring from file: hibernate.cfg.xml
[schemaExport] 17:00:50,609 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
[schemaExport] 17:00:50,625 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[schemaExport] 17:00:50,625 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - hibernate.connection.driver_class=org.hsqldb.jdbcDriver
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - hibernate.connection.url=jdbc:hsqldb:hsql://localhost/db1
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - hibernate.connection.username=sa
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - hibernate.default_schema=PUBLIC
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - hibernate.dialect=org.hibernate.dialect.HSQLDialect
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - current_session_context_class=thread
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - show_sql=true
[schemaExport] 17:00:50,671 DEBUG Configuration:1387 - connection.pool_size=1
[schemaExport] 17:00:50,671 DEBUG Configuration:1586 - null<-org.dom4j.tree.DefaultAttribute@87c268 [Attribute: name resource value "sca/hibernate1/entities/Person.hbm.xml"]
[schemaExport] 17:00:50,671 INFO Configuration:553 - Reading mappings from resource : sca/hibernate1/entities/Person.hbm.xml
[schemaExport] 17:00:50,687 DEBUG DTDEntityResolver:38 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd]
[schemaExport] 17:00:50,687 DEBUG DTDEntityResolver:40 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
[schemaExport] 17:00:50,687 DEBUG DTDEntityResolver:50 - located [http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd] in classpath
[schemaExport] 17:00:50,781 INFO HbmBinder:300 - Mapping class: sca.hibernate1.entities.Person -> H_PERSON

BUILD FAILED
D:\Callisto\workspaces\default\hibernate1\build-mv.xml:15: Schema text failed: Could not parse mapping document from resource sca/hibernate1/entities/Person.hbm.xml

Total time: 1 second

Name and version of the database you are using:

hsqldb 1.8.0

Merci d'avance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 09, 2007 7:07 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Question idiote : je suppose que tu as bien un fichier de mapping dans le package sca/hibernate1/entities/ ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 10, 2007 2:12 pm 
Newbie

Joined: Fri Sep 23, 2005 6:44 am
Posts: 5
Oui, la 5° ligne avant la fin de la log indique qu'il le lit et ensuite il cherche les dtd reférencées par le mapping. Il n'y a aucune indication sur la raison pour laquelle il n'arrive pas à le parser. J'ai essayé en ligne de commande ca ne marche pas non plus. Je vais finir par l'executer en mode debug ou chercher un autre outil ce truc ne m'a pas l'air très fiable.


Top
 Profile  
 
 Post subject: Contournement
PostPosted: Wed Mar 14, 2007 10:01 am 
Newbie

Joined: Fri Sep 23, 2005 6:44 am
Posts: 5
SchemaExport fonctionne avec les même fichiers de mapping & config Hibernate mais en étant lancé dans eclipse. Pas un problème de parsing donc, mais plutôt d'environement.


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.