"Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml"

343 views Asked by At

A newbie here !!!My doubt is regarding HIBERNATE programming,i am getting this error which i am not able to resolve even after doing so much research ! First time when i executed program it got successfully processed and the values were inserted in database, but all of sudden i am getting this error and since then not able to move forward !! PS: when i try to run same program in my friends computer, it works :/


Below is the ERROR in CONSOLE :

Exception in thread "main" org.hibernate.Hiberna`enter code here`teException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)    
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)    
at com.snycon.hibernateEx.EmployeeAction.main(EmployeeAction.java:13)    

Caused by: org.dom4j.DocumentException: Unexpected end of file from server Nested exception: Unexpected end of file from server
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481) ... 2 more c


Below is my hibernate.cfg.xml file :

<?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>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
       <property name="connection.url">jdbc:mysql://localhost:3306/jdbcex</property>
       <property name="connection.username">root</property>
       <property name="connection.password">root</property>
       <property name="show_sql">true</property>
       <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
       <property name="hbm2ddl.auto">update</property>
        <mapping resource="employee.hbm.xml"/>
        </session-factory>

    </hibernate-configuration>

1

There are 1 answers

0
Jay Smith On BEST ANSWER

Change schema declaration of hibernate.cfg.xml to:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
 "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
 "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">