Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By doWhile

Thread: org.hibernate.HibernateException: Could not parse configurat

  1. #1
    Zahir Ullah is offline Member
    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Lightbulb org.hibernate.HibernateException: Could not parse configurat

    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.setUserId(1);
    user.setUserName("First User");
    SessionFactory sessionFactory=new Configuration().configure().buildSessionFactory();
    Session session=sessionFactory.openSession();
    session.beginTransaction();
    session.save(user);
    session.getTransaction().commit();
    }
    catch(HibernateException e)
    {
    e.printStackTrace();
    }

    }
    }

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

    @Entity
    public class UserDetails {
    @Id
    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;
    }
    }

    hibernate.cfg.xml
    <?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" />
    </session-factory>
    </hibernate-configuration>

    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
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

Similar Threads

  1. Replies: 3
    Last Post: 12-27-2011, 05:16 PM
  2. Could not parse configuration: /hibernate.cfg.xml
    By Matang in forum Web Frameworks
    Replies: 2
    Last Post: 04-10-2011, 03:28 PM
  3. using parse
    By mustachMan in forum New To Java
    Replies: 2
    Last Post: 01-15-2010, 02:32 AM
  4. SAX Parse
    By bluefloyd8 in forum New To Java
    Replies: 1
    Last Post: 01-25-2008, 04:57 PM
  5. Replies: 2
    Last Post: 06-30-2007, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •