0

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>

4
  • can you paste your hibernate.cfg.xml. looks like you made some accidental changes in that. can you try reverting them and try again? Commented May 2, 2017 at 4:41
  • Hi @AmitK , have posted the configuration file .. and yes i have tried reverting,creating new one many time !! stilll no luck !! ... also i found ppl saying it might be problem with spaces or so ,, so i tried creating xml file using xml editor which downloaded from eclipse market place..but still same ERROR Commented May 2, 2017 at 5:05
  • Remove the extra space from beginning of first line in hibernate.cfg.xml Commented May 2, 2017 at 5:06
  • oops ! actually there are no spaces ,i donno somehow when i post here i mean in "stackoverflow" its giving me problems to post as it is ,, so i added spaces, i am trying to share pic .. but its telling i don't have enough points to share pics yet !:( Commented May 2, 2017 at 5:12

1 Answer 1

1

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">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.