Hibernate - H2 db -- Could not parse mapping document from resource
Posted
by
user1849757
on Stack Overflow
See other posts from Stack Overflow
or by user1849757
Published on 2012-11-24T17:02:11Z
Indexed on
2012/11/24
17:03 UTC
Read the original article
Hit count: 270
hibernate
* Each of below files are in same location *
Error :
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. org.hibernate.InvalidMappingException: Could not parse mapping document from resource ./employee.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:616) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556) at org.hibernate.cfg.Configuration.configure(Configuration.java:1476) at org.hibernate.cfg.Configuration.configure(Configuration.java:1462) at com.yahoo.hibernatelearning.FirstExample.main(FirstExample.java:19) Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:555) at org.hibernate.cfg.Configuration.addResource(Configuration.java:613) ... 7 more Caused by: org.dom4j.DocumentException: http://hibernate.sourceforge.net/%0Ahibernate-mapping-3.0.dtd Nested exception: http://hibernate.sourceforge.net/%0Ahibernate-mapping-3.0.dtd at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:546) ... 8 more Exception in thread "main" java.lang.NullPointerException at com.yahoo.hibernatelearning.FirstExample.main(FirstExample.java:33)
Hibernate Config: hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.h2.Driver</property>
<property name="hibernate.connection.url">jdbc:h2:./db/repository</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.default_schema">PUBLIC</property>
<property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="./employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Mapping Config: employee.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>
<class name="com.yahoo.hibernatelearning.Employee" table="employee">
<id name="empId" type="int" column="emp_id" >
<generator class="native"/>
</id>
<property name="empName">
<column name="emp_name" />
</property>
<property name="empSal">
<column name="emp_sal" />
</property>
</class>
</hibernate-mapping>
© Stack Overflow or respective owner