Could not parse configuration: /hibernate.cfg.xml

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08
Could you help please!

This errors appearse when I try to connect to the database and try to create a session Factory,  any suggestion!

10/01/11 16:41:02 %%%% Error Creating SessionFactory %%%%
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1500)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
        at com.bancoazteca.srm.modelo.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:68)
        at com.bancoazteca.srm.modelo.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:44)
        at com.bancoazteca.srm.modelo.dao.transaccion.Transaccion.obtenerConexionSrm(Transaccion.java:405)
        at com.bancoazteca.srm.arquitectura.business.LogonADNDelegate.buscaSucursalExistenciaS(LogonADNDelegate.java:370)
        at com.bancoazteca.srm.arquitectura.business.LogonADNDelegate.buscaExistenciaSucursal(LogonADNDelegate.java:352)
        at com.bancoazteca.srm.control.action.logueo.LogonADNAction.execute(LogonADNAction.java:79)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
        at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
        at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
        at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
        at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
        at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
        at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
        at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
        at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.dom4j.DocumentException:  Nested exception:
        at org.dom4j.io.SAXReader.read(SAXReader.java:484)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1490)
Question by:osmendez
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +3
LVL 20

Expert Comment

ID: 26290196
"Caused by: org.dom4j.DocumentException:  Nested exception:
        at org.dom4j.io.SAXReader.read(SAXReader.java:484)"

Seems like the cfg file is not correctly formatted. Please post the file.
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26290516
is this
<?xml version='1.0' encoding='utf-8'?>
appere in 1st line of ur xml file ???

Please post the code !!

LVL 86

Expert Comment

ID: 26291281
Try validating your config file

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

LVL 12

Expert Comment

by:Gibu George
ID: 26292529
If possible please post your hibernate.cf.xml

Author Comment

ID: 26294598
Sure my xml file is this

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
 <property name="connection.username">user</property>

  <property name="connection.url">jdbc:oracle:thin:@Server:1521:ORCL</property>
  <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
  <property name="myeclipse.connection.profile">Oracle</property>
  <property name="connection.password">passwd</property>
  <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  <property name="connection.autocommit">false</property>
  <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
  <property name="hibernate.c3p0.idle_connection_test_period">60</property>
  <property name="hibernate.c3p0.automatic_test_table">test_table</property>
  <property name="hibernate.c3p0.validate">true</property>
  <property name="hibernate.c3p0.propertyCycle">2</property>
  <property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
  <property name="hibernate.c3p0.max_statements">100</property>
  <property name="hibernate.c3p0.max_size">200</property>
  <property name="hibernate.c3p0.min_size">15</property>
  <property name="hibernate.c3p0.maxConnectionAge">60</property>
  <property name="hibernate.c3p0.maxIdleTime">60</property>
  <property name="hibernate.c3p0.timeout">360</property>
  <property name="hibernate.c3p0.idle_test_period">180</property>
  <property name="hibernate.c3p0.acquire_increment">1</property>

LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26295247
<property name="connection.username">'

dont use conection infront the name filed.. its predefinded one
<property name="username"> use like this for other flied also

Author Comment

ID: 26295778
I have used this xml for 5 months, this error ocurred yestarday I don't undertand wich is the reason,  I'll try with your suggetion
LVL 86

Expert Comment

ID: 26295809
>>, this error ocurred yestarday

What changes have occurred recently?
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26295862
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>

; is coming after the value check????????/

Author Comment

ID: 26296905
I did not  any change, and this line <property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
was in an example.  I don't know its funcionality
LVL 20

Expert Comment

ID: 26300304
By any chance have the hibernate jars been changed or upgraded?
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26304275
Have u check that remove connection ??? in ur propert filed!!

LVL 11

Accepted Solution

anilallewar earned 1000 total points
ID: 26311381
The TestQuery "Select 1;" is incorrect as you have not provided either a valid schema name or dual. Can you change it to the below and check? I really don't see that should cause a parsing error but give it a try nonetheless.

<property name="hibernate.c3p0.preferredTestQuery">select 1 from dual;</property>

Author Comment

ID: 26346448
I can't understand why ocurred that error just one time. I think that  <property name="hibernate.c3p0.preferredTestQuery">select 1 from dual;</property> don't resolve my doubt because it just be a parameter, and the error it would be other, thanks four your help

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question