Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Default org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

    hi dear i am new user of hibernate please anyone solve my problem i am using hibernate 4, PostgreSQL and eclipse i face the following error

    org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Config uration.java:2023)
    at org.hibernate.cfg.Configuration.configure(Configur ation.java:1935)
    at org.hibernate.cfg.Configuration.configure(Configur ation.java:1914)
    at org.koushik.hibernate.HibernateTest.main(Hibernate Test.java:19)
    Caused by: org.dom4j.DocumentException: Error on line 1 of document : The processing instruction target matching "[xX][mM][lL]" is not allowed. Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.hibernate.cfg.Configuration.doConfigure(Config uration.java:2015)
    ... 3 more
    i am using that classes
    package org.koushik.hibernate;
    import org.hibernate.HibernateException;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
    import org.javabrains.koushik.dto.UserDetails;

    public class HibernateTest {

    * @param args
    public static void main(String[] args) {
    try{ // TODO Auto-generated method stu
    UserDetails user=new UserDetails();
    user.setUserName("First User");
    SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
    Session session=sessionFactory.openSession();
    catch(HibernateException e)


    package org.javabrains.koushik.dto;
    import javax.persistence.Entity;
    import javax.persistence.Id;

    public class UserDetails {
    private int userId;
    private String userName;
    public int getUserId() {
    return userId;
    public void setUserId(int userId) {
    this.userId = userId;
    public String getUserName() {
    return userName;
    public void setUserName(String userName) {
    this.userName = userName;

    <?xml version="1.0" encoding="utf-8" ?>
    - <!-- ~ Hibernate, Relational Persistence for Idiomatic Java
    ~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as
    ~ indicated by the @author tags or express copyright attribution
    ~ statements applied by the authors. All third-party contributions are
    ~ distributed under license by Red Hat Inc.
    ~ This copyrighted material is made available to anyone wishing to use, modify,
    ~ copy, or redistribute it subject to the terms and conditions of the GNU
    ~ Lesser General Public License, as published by the Free Software Foundation.
    ~ This program is distributed in the hope that it will be useful,
    ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
    ~ for more details.
    ~ You should have received a copy of the GNU Lesser General Public License
    ~ along with this distribution; if not, write to:
    ~ Free Software Foundation, Inc.
    ~ 51 Franklin Street, Fifth Floor
    ~ Boston, MA 02110-1301 USA-->
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.6//EN""http://www.hibernate.org/dtd/hibernate-configuration-3.6.dtd">
    - <hibernate-configuration>
    - <session-factory>
    - <!-- Database connection settings
    <property name="connection.driver_class">org.postgresql.Driv er</property>
    <property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">password</property>
    - <!-- JDBC connection pool (use the built-in)
    <property name="connection.pool_size">1</property>
    - <!-- SQL dialect
    <property name="dialect">org.hibernate.dialect.PostgreSQLDia lect</property>
    - <!-- Disable the second-level cache
    <property name="cache.provider_class">org.hibernate.cache.No CacheProvider</property>
    - <!-- Echo all executed SQL to stdout-->
    <property name="show_sql">true</property>
    - <!-- Drop and re-create the database schema on startup
    <property name="hbm2ddl.auto">create</property>
    - <!-- Names the annotated entity class
    <mapping class="org.javabrains.koushik.dto.UserDetails" />

    I also add the following jar file
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\envers\hibernate-envers-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\jpa\hibernate-entitymanager-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\c3p0\hibernate-c3p0-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\c3p0\c3p0-0.9.1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\ehcache\ehcache-core-2.4.3.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\ehcache\hibernate-ehcache-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\ehcache\slf4j-api-1.6.1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\hibernate-infinispan-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\hibernate-infinispan-4.1.9.Final-tests.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\infinispan-core-5.2.0.Beta3.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\jboss-logging-3.1.1.GA.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\jboss-marshalling-1.3.15.GA.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\jboss-marshalling-river-1.3.15.GA.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\jgroups-3.2.0.CR1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\rhq-pluginAnnotations-3.0.4.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\stax2-api-3.1.1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\staxmapper-1.1.0.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\infinispan\woodstox-core-asl-4.1.1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\proxool\hibernate-proxool-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\optional\proxool\proxool-0.8.3.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\antlr-2.7.7.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\dom4j-1.6.1.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\hibernate-commons-annotations-4.0.1.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\hibernate-core-4.1.9.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\hibernate-jpa-2.0-api-1.0.1.Final.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\javassist-3.17.1-GA.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\jboss-logging-3.1.0.GA.jar
    C:\Program Files\Java\hibernate-release-4.1.9.Final\lib\required\jboss-transaction-api_1.1_spec-1.0.0.Final.jar

    the following is the data base driver
    C:\Program Files\Java\jdbc\postgresql-9.2-1002.jdbc4.jar

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Thanked 0 Times in 0 Posts

    Default Re: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

    please any one tell me which jar file i change to solve the problem

Similar Threads

  1. [SOLVED] "org.hibernate.Session" ClassNotFoundException
    By talha06 in forum Exceptions
    Replies: 3
    Last Post: August 21st, 2013, 11:13 AM
  2. Hibernate
    By kchandan38 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 6th, 2012, 07:48 AM
  3. what is the work can hibernate.cfg.xml do?
    By bob.indiang in forum JDBC & Databases
    Replies: 0
    Last Post: August 12th, 2012, 11:29 AM
  4. Replies: 0
    Last Post: July 27th, 2011, 10:31 AM
  5. Hibernate Concepts
    By systech44 in forum Web Frameworks
    Replies: 2
    Last Post: March 12th, 2010, 07:32 AM