-->
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
PostPosted: Thu Nov 23, 2006 7:53 am 
Newbie

Joined: Mon Oct 23, 2006 12:27 am
Posts: 4
Location: sri lanaka
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:
<?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="Student" table="student">
<id name="id" column="_indexno">
<generator class="native"/>
</id>
<property name="fname" type="text" column="_fname"/>
<property name="lname" type="text" column="_lname"/>
<property name="age" type="int" column="_age"/>
<property name="school" type="text" column="_school"/>
</class>

</hibernate-mapping>


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

public static void main(String[] args) {
StudentManager mgr = new StudentManager();
mgr.createAndStoreStudent();
HibernateUtil.getSessionFactory().close();
}

private void createAndStoreStudent() {

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Student s = new Student("janaka","priyadarshana", 23, "wrmmv");
session.save(s);
session.getTransaction().commit();
}

}


Full stack trace of any exception that occurs:


C:\Borland\JBuilder2006\jdk1.5\bin\javaw -classpath "C:\Documents and Settings\Janaka Priyadarshana\jbproject\HibernateTesting\classes;C:\hibernate-3.2\hibernate3.jar;C:\hibernate-3.2\lib\commons-collections-2.1.1.jar;C:\hibernate-3.2\lib\asm.jar;C:\hibernate-3.2\lib\syndiag2.jar;C:\hibernate-3.2\lib\cglib-2.1.3.jar;C:\hibernate-3.2\lib\jgroups-2.2.8.jar;C:\hibernate-3.2\lib\jta.jar;C:\hibernate-3.2\lib\swarmcache-1.0rc2.jar;C:\hibernate-3.2\lib\ant-1.6.5.jar;C:\hibernate-3.2\lib\jdbc2_0-stdext.jar;C:\hibernate-3.2\lib\hsqldb.jar;C:\hibernate-3.2\lib\proxool-0.8.3.jar;C:\hibernate-3.2\lib\log4j-1.2.11.jar;C:\hibernate-3.2\lib\antlr-2.7.6.jar;C:\hibernate-3.2\lib\ant-junit-1.6.5.jar;C:\hibernate-3.2\lib\jacc-1_0-fr.jar;C:\hibernate-3.2\lib\versioncheck.jar;C:\hibernate-3.2\lib\jboss-cache.jar;C:\hibernate-3.2\lib\jboss-system.jar;C:\hibernate-3.2\lib\jboss-common.jar;C:\hibernate-3.2\lib\cleanimports.jar;C:\hibernate-3.2\lib\ant-antlr-1.6.5.jar;C:\hibernate-3.2\lib\ant-swing-1.6.5.jar;C:\hibernate-3.2\lib\concurrent-1.3.2.jar;C:\hibernate-3.2\lib\commons-logging-1.0.4.jar;C:\hibernate-3.2\lib\c3p0-0.9.0.jar;C:\hibernate-3.2\lib\connector.jar;C:\hibernate-3.2\lib\ant-launcher-1.6.5.jar;C:\hibernate-3.2\lib\jboss-jmx.jar;C:\hibernate-3.2\lib\xerces-2.6.2.jar;C:\hibernate-3.2\lib\dom4j-1.6.1.jar;C:\hibernate-3.2\lib\junit-3.8.1.jar;C:\hibernate-3.2\lib\xml-apis.jar;C:\hibernate-3.2\lib\oscache-2.1.jar;C:\hibernate-3.2\lib\asm-attrs.jar;C:\hibernate-3.2\lib\javassist.jar;C:\hibernate-3.2\lib\ehcache-1.2.jar;C:\hibernate-3.2\lib\jaxen-1.1-beta-7.jar;C:\hibernate-3.2\lib\jaas.jar;C:\hibernate-3.2\lib\checkstyle-all.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\plugin.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\rt.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\dnsns.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\sunpkcs11.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\sunjce_provider.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\ext\localedata.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\im\indicim.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\im\thaiim.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\javaws.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\deploy.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\jsse.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\jce.jar;C:\Borland\JBuilder2006\jdk1.5\jre\lib\charsets.jar;C:\Borland\JBuilder2006\jdk1.5\lib\tools.jar;C:\Borland\JBuilder2006\jdk1.5\lib\jconsole.jar;C:\Borland\JBuilder2006\jdk1.5\lib\htmlconverter.jar;C:\Borland\JBuilder2006\jdk1.5\lib\dt.jar" student.StudentManager
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at student.StudentManager.createAndStoreStudent(StudentManager.java:17)
at student.StudentManager.main(StudentManager.java:11)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource student/Student.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:523)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1511)Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource student/Student.hbm.xml

at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
Caused by: org.hibernate.MappingException: class Student not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:74)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:401)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:334)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
at org.hibernate.cfg.Configuration.add(Configuration.java:424)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:465)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:520)
... 9 more
Caused by: java.lang.ClassNotFoundException: Student
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:70)
... 17 more



Name and version of the database you are using:

postgresql 8.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 24, 2006 8:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not a tooling question - use the user forum (or simply read and understand the exception)

_________________
Max
Don't forget to rate


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.