File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Invalid mapping exception in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Invalid mapping exception in Hibernate" Watch "Invalid mapping exception in Hibernate" New topic
Author

Invalid mapping exception in Hibernate

Vineeth Kumar N
Greenhorn

Joined: Jan 02, 2012
Posts: 3
I'm trying to create my First Hibernate program and i am facing "Invalid mapping Exception".My

echo.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-
2.0.dtd" >
<hibernate-mapping package="com.org.hibernate">
<class name="Echo" table="echo_message">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="name" column="msg" type="java.lang.String" />
</class>
</hibernate-mapping>

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">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://localhost/hibernate_db
</property>
<property name="connection.username">root</property>
<property name="connection.password">vinu</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">test</property>
<mapping resource="com/org/hibernate/echo.hbm.xml" />

</session-factory>

</hibernate-configuration>

TestClient.java

package com.org.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;


public class TestClient {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Session session = null;
Transaction tx = null;
session = HibernateSessionFactory.getSession();
tx = session.beginTransaction();
Echo e = (Echo)session.get(Echo.class, 1);
System.out.println(e.getName());
tx.commit();
session.close();
}

}


When i am trying to run theTestClient.java
this exception is thrown



log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/org/hibernate/echo.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at com.org.hibernate.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:30)
at com.org.hibernate.TestClient.main(TestClient.java:17)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 7 more
Caused by: org.dom4j.DocumentException: Illegal character in URL Nested exception: Illegal character in URL
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
... 8 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/org/hibernate/echo.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at com.org.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at com.org.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at com.org.hibernate.TestClient.main(TestClient.java:17)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 8 more
Caused by: org.dom4j.DocumentException: Illegal character in URL Nested exception: Illegal character in URL
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
... 9 more
Exception in thread "main" java.lang.NullPointerException
at com.org.hibernate.TestClient.main(TestClient.java:18)


Please guide me
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Invalid mapping exception in Hibernate
 
Similar Threads
Invalid Mapping Exception while inserting data through hibernate
Hibernate table per class hierarchy
Hibernate table per class hierarchy
I am new on Hibernate
Duplicate class/entity mapping error