-->
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.  [ 7 posts ] 
Author Message
 Post subject: Could not parse mapping document from resource...
PostPosted: Wed Aug 01, 2007 5:05 pm 
Newbie

Joined: Wed Aug 01, 2007 4:53 pm
Posts: 11
i'm learning JSF for the moment and thought it was a good moment to use hibernate with it for my access layer... all said and done, i downloaded hibernate, read the tutorial and tried something on my own but unfortunattly i get an error:

org.hibernate.InvalidMappingException: Could not parse mapping document from resource DAL/Users.hbn.xml

This is my Users.hbn.xml:
Code:
<?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>
    <class name="DAL.Users" table="USERS">
        <id name="id" column="id">
            <generator class="native"/>
        </id>
        <property name="userid"/>
        <property name="name"/>
        <propery name="firstname"/>
    </class>
</hibernate-mapping>


and this is my hibernate.cfg.xml

Code:
<?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>

        <!-- Database connection settings -->
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">...</property>
        <property name="connection.username">...</property>
        <property name="connection.password">...</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <mapping resource="DAL/Users.hbn.xml"/>

    </session-factory>

</hibernate-configuration>


The mapping of my files are:

+src
---hibernate.cfg.xml
---DAL
------Users.hbn.xml
------Users.java

When i compile, i get the same file but in the /classes dir. All the xml's are also in that dir or subdir.

I really can't see what the problem is... [/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 5:23 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
I really can't see what the problem is...


Neither can anybody else because you did cut off the rest of the exception message with the real cause.

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


Top
 Profile  
 
 Post subject: Yes You Can See His Problem
PostPosted: Wed Aug 01, 2007 5:31 pm 
Newbie

Joined: Fri Apr 07, 2006 11:29 am
Posts: 17
If you copied that exception, then you will see that your mapping file is likely named Users.hbm.xml rather than Users.hbn.xml

Another thing that might cause this is that if the compile, as you suggested, took the hbm file out of the DAL directory, referencing it from the DAL directory wouldn't work. In other words, if there is no DAL directory after your compile, you would need to change
Code:
<mapping resource="DAL/Users.hbn.xml"/> 
to
<mapping resource="Users.hbn.xml"/>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 2:08 am 
Newbie

Joined: Wed Aug 01, 2007 4:53 pm
Posts: 11
When i change the <mapping resource="DAL/Users.hbn.xml"/> part of the config, i get another exception saying that the file can't be found so i'm sure the file is in the correct dir, even after compilation.

I looked in the compilation dir and the Users.hbn.xml is really in the classes\DAL\ dir


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 02, 2007 7:13 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
You've got a spelling mistake in your file:
<propery name="firstname"/>
should be
<property name="firstname"/>
You're missing a "t"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 03, 2007 2:31 am 
Newbie

Joined: Wed Aug 01, 2007 4:53 pm
Posts: 11
Yes thanks... that was the problem


Top
 Profile  
 
 Post subject: Re: Could not parse mapping document from resource...
PostPosted: Sun Jul 03, 2011 2:55 am 
Newbie

Joined: Sun Jul 03, 2011 2:33 am
Posts: 1
i got the same problem and i don't know

this is my problem:
org.hibernate.InvalidMappingException: Could not parse mapping document from URL file:/C:/Users/owner/Desktop/Proyecto CBR Produccion/bin/jcolibri/proyecto/RecomendadorProduccion/DescripcionProduccion.hbm.xml

this is my DescripcionProduccion.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="jcolibri.proyecto.RecomendadorProduccion.DescripcionProduccion" table="Ropa">

   <id name="caseId" column="caseId">
     <generator class="native"/>
   </id>
   <property name="tipoRopa" column="tipoRopa"/>
   <property name="numPrendas" column="numPrendas"/>
   <property name="materiaPrima" column="materiaPrima">
      <type name="jcolibri.connector.databaseutils.GenericUserType">
         <param name="className">jcolibri.datatypes.Instance</param>
      </type>
   </property>
   <property name="Talla" column="Talla"/>
   <property name="Color" column="Color">
      <type name="jcolibri.connector.databaseutils.EnumUserType">
         <param name="enumClassName">jcolibri.proyecto.RecomendadorProduccion.DescripcionProduccion$Colores</param>
       </type>
     </property>
   <property name="Calidad" column="Calidad">
      <type name="jcolibri.connector.databaseutils.EnumUserType">
         <param name="enumClassName">jcolibri.proyecto.RecomendadorProduccion.DescripcionProduccion$TiposCalidades</param>
       </type>
     </property>

</class>
</hibernate-mapping>


and this is my file hibernate.cfg.xml
Code:
<?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>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:hsql://localhost/Ropa</property>
        <property name="connection.username">sa</property>
      <property name="connection.password"></property>
      
        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>
   
    </session-factory>
</hibernate-configuration>


i really need the help i only got 3 or 4 days to fix it.


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