-->
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.  [ 2 posts ] 
Author Message
 Post subject: "Could not parse mapping document from resource.." Problem
PostPosted: Sun May 16, 2010 4:34 pm 
Newbie

Joined: Sat May 15, 2010 8:21 am
Posts: 4
hello, i am trying to make an school project, but i have some problems


i have this class

Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package biblioteca.model;

import java.util.HashSet;
import java.util.Set;

/**
*
* @author Alx
*/
public class Abonat {

    private int codAbonat;
    private String nume;
    private int codBiblioteca;
    private float penalitati;
    private Set<Carte> cartiImprumutate = new HashSet<Carte>(0);

    public Abonat(){

    }

    public int getCodAbonat(){
        return codAbonat;
    }

    public void setCodAbonat(int codAbonat){
        this.codAbonat = codAbonat;
    }

    public String getNume(){
        return nume;
    }

    public void setNume(String nume){
        this.nume = nume;
    }

    public int getCodBiblioteca(){
        return codBiblioteca;
    }

    public void setCodBiblioteca(int codBiblioteca){
        this.codBiblioteca = codBiblioteca;
    }

    public float getPenalitati(){
        return penalitati;
    }

    public void setPenalitati(float penalitati){
        this.penalitati = penalitati;
    }

    public Set<Carte> getCartiImprumutate(){
        return cartiImprumutate;
    }

    public void setCartiImprumutate(Set<Carte> cartiImprumutate){
        this.cartiImprumutate = cartiImprumutate;
    }

}





this 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>
    <class name="Abonat" table="abonat">
        <meta attribute="class-description">This class contains abonat details.</meta>
       <id name="id" >
            <generator class="native" />
        </id>
        <property name="codAbonat" type="int" not-null="true" column="codAbonat" />
        <property name="nume" type="string" length="45" not-null="true" column="nume" />
        <property name="codBiblioteca" type="int" not-null="true" column="codBiblioteca" />
        <property name="penalitati" type="float" not-null="true" column="penalitati" />
        <set name="carti" table="carte_abonat" cascade="all">
            <key column="codAbonat" />
            <many-to-many column="codCarte" unique="true" class="Carte" />
        </set>
    </class>
</hibernate-mapping>




and this is the 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 name="sessionFactory">
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.autocommitt">true</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
        <property name="connection.username">root</property>
        <property name="connection.password">mami</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.current_session_context_class">thread</property>
  <mapping resource="biblioteca/model/Abonat.hbm.xml" />
</session-factory>
  </hibernate-configuration>





and this are the errors
Code:
run:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource biblioteca/model/Abonat.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.<clinit>(HibernateUtil.java:29)
        at biblioteca.BibliotecaApp.main(BibliotecaApp.java:49)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource biblioteca/model/Abonat.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:602)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1621)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1496)
        at util.HibernateUtil.<clinit>(HibernateUtil.java:25)
        ... 1 more
Caused by: org.hibernate.MappingException: class Abonat not found while looking for property: id
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:97)
        at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)
        at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:423)
        at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:356)
        at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
        at org.hibernate.cfg.Configuration.add(Configuration.java:702)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:599)
        ... 7 more
Caused by: java.lang.ClassNotFoundException: Abonat
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:123)
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:93)
        ... 15 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)



could you please help me


Top
 Profile  
 
 Post subject: Re: "Could not parse mapping document from resource.." Problem
PostPosted: Mon May 17, 2010 11:25 am 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
Each table must have a mapping file. Try to create a mapping file for the other table and provide the table info in the mapping file instead of the set. Also the owner table would have one-to-many relation and the other would have many-to-one relation in the mapping file. The set will have the common column that connects the two tables.


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