Share on Google+Share on Google+

kamlesh prajapati
Could not parse configuration: hibernate.cfg.xml
1 Answer(s)      3 years and 11 months ago
Posted in : Hibernate
Hi,
I am getting the error-

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
    at com.javatpoint.mypackage.StoreData.main(StoreData.java:14)
Caused by: org.dom4j.DocumentException: C:\Users\kamlesh\workspace\empdetails\hibernate-configuration-3.0.dtd (The system cannot find the file specified) Nested exception: C:\Users\kamlesh\workspace\empdetails\hibernate-configuration-3.0.dtd (The system cannot find the file specified)
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1532)
    ... 2 more

hibernate.cfg.xml file-


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd" >
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="hbm2ddl.auto"></property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">system</property>
<property name="connection.password">mansi2985</property>
<property name="dialect"> org.Hibernate.dialect.OracleDialect </property>

<mapping resource="employee.hbm.xml" />

</session-factory>
</hibernate-configuration>


StoreData.java-

package com.javatpoint.mypackage;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;


public class StoreData {

    public static void main(String[] args){
        //creating configuration object
        Configuration cfg=new Configuration();
        cfg.configure("hibernate.cfg.xml");    //populates the data of the configuration file

        //creating session factory object
        SessionFactory factory=cfg.buildSessionFactory();

        //creating session object
        Session session=factory.openSession();

        //creating session transaction
        Transaction t=session.beginTransaction();

        Employee e1=new Employee();
        e1.setId(115);
        e1.setFirstName("ritesh");
        e1.setLastName("kamlesh");

        session.persist(e1);    //persisting the object

        t.commit();                //transaction is committed

        session.close();

        System.out.println("sussessfully printed");

        }


}

Ads

View Answers

April 24, 2013 at 1:06 PM


hibernate.cfg.xml file-

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "hibernate-configuration-3.0.dtd" >
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="hbm2ddl.auto"></property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="connection.username">system</property>
<property name="connection.password">-----</property>
<property name="dialect"> org.Hibernate.dialect.OracleDialect </property>

<mapping resource="employee.hbm.xml" />

</session-factory>
</hibernate-configuration>









Related Tutorials/Questions & Answers:
Could not parse configuration: hibernate.cfg.xml
Could not parse configuration: hibernate.cfg.xml  Hi, I am getting the error- log4j:WARN No appenders could be found for logger.... Exception in thread "main" org.hibernate.HibernateException: Could not parse
org.hibernate.InvalidMappingException: Could not parse mapping document - Hibernate
org.hibernate.InvalidMappingException: Could not parse mapping document .... Exception occur:Could not parse mapping document from resource event/Sample.hbm.xml org.hibernate.InvalidMappingException: Could not parse mapping
Advertisements
parse in iphone
parse in iphone  <p>{ itemCount: 2, subtotal: "$15.50", items:[ { title: "The Big Book of Foo", description: "Bestselling book of Foo by A.N. Other", imageUrl: "/images/books/12345.gif
parse xml
parse xml   <STATES> <STATE sname="AndhraPradesh" > <DISTRICT dname="Ananthapur" > <address> Apollo...; </STATE> How to parse the above xml. please help me   Here
parse url iphone sdk
parse url iphone sdk  How can i parse two different URL's using NSXMLParser
php parse string to time
php parse string to time  I am looking for a solution to parse a string into a formatted date time string
parse map in java
parse map in java  What is a Parser? Can you give the source code to parse map in Java
php parse string for url
php parse string for url  Do i need a regex to parse a URL-type string in PHP
php parse ini string
php parse ini string  Need to know how to parse the ini file to extract values
php parse string into array
php parse string into array  How can i parse a string into array and convert an array into string
php parse ini array
php parse ini array  I wanted to parse a variable inside a variable value. Can any one give the example
php parse string to float
php parse string to float  Is there any Regex or way to get float from a string
php parse string as php
php parse string as php  Best way of parsing a string within a string
php parse soap response
php parse soap response  What is soap and how can i convert a soap response to XML. Thanks in Advance
php parse ini file
php parse ini file  I need a simple and easy example to Parsing an ?advanced? INI file with PHP
php parse subdomain
php parse subdomain  Basically, looking for a example on how to let PHP to create subdomain automatically for each user? Is it possible to retrieve subdomain as a get variable
php parse string to date
php parse string to date  In my app i have a date string in the following format: $date = "08/20/2009"; Can you suggest how can i separate each part of the date
php parse string as int
php parse string as int  While trying to pass string to int using int() i get the following error: Call to undefined function int() Why it is throwing an error
date_parse
date_parse() in PHP date_parse function returns associative array... error. Description on Date Parse Format in PHP array date_parse ( string $date ) Parameters of date parse class PHP date - Date in format accepted
could not start server. - EJB
could not start server.  Dear All I have installed netbeans 5.5.1 and sun java Application server 9.2 to run ejb program. But when I start... comes ---sun java server could not start. so what should I do to start this server
could someone help in this ........
could someone help in this ........  dear Sir/Mrs I'll be thankful for helping me on this ....... write a program that reads 10 numbers. find the largest number and count the occurrence of the largest number from a declared
JavaScript parse date
JavaScript parse date..., you will learn how to parse the date in JavaScript. JavaScript provides the function parse() that takes a date in string format and returns the equivalent
could not connect to the server - JDBC
could not connect to the server  Hii sir, I am working with a JBDC program now. Now i am trying to host it. when i am trying to connect to the remote MySqL server, i got an exception like
Could not able to load jar file - WebSevices
Could not able to load jar file  Hi, I tried to parse the xml file to a java object. I followed the procedure that you have mentioned in the website. I created one batch file that consists of all
parse data from a link in java
parse data from a link in java  Hi, Here I want code for Extracting data from a link and the data a must be stored in mysql and then I need to display the data in a jsp page
how to parse xml in j2me tutorial
how to parse xml in j2me tutorial   i want to parse xml file in j2me wireless toolkit.i saw ur examples & source code for parsing xml file in j2me & i try to execute same example on my pc i some how manage to run
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  I am getting the following exception while running Hibernate example, pls..." org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  I am getting the following exception while running Hibernate example, pls..." org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  I am getting the following exception while running Hibernate example, pls..." org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  I am getting the following exception while running Hibernate example, pls..." org.hibernate.MappingException: could not instantiate id generator
Could not open JPA EntityManager for transaction
Could not open JPA EntityManager for transaction  Hi, I am getting following error: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException
Tutorials   
Java Spring Hibernate Struts Training java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based! org.hibernate.validator cannot be resolved error java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion java.lang.ClassNotFoundException: org.hibernate.cache.TimestampsRegion property hibernate.cache.region.factory_class is not given Hibernate example step by step in Eclipse with MySQL How to make Struts Hibernate and Spring Based Login/Registration Application? What is the use of Hibernate Native SQL? What is the use of Hibernate is used? How to integrate Struts and Hibernate in an application? How to create the program in Java for getting the forgotten Password Form? How to write create JPA Many-to-Many Relationship in Java? What is the DAO Layer in any application? What is Spring Struts Hibernate DAO Layer? How to write Example code for CRUD application in hibernate annotation? Where to update the Hibernate tools? Query conversion convert into hql how to convert sql into hql package org.hibernate.util does not exist C3P0 with Hibernate What do you understand by JPA? Hibernate Query Checker Jpa many to many relationship What do you understand by Hibernate in Java? What are criteria Queries in Hibernate? How to use Associations and Joins in Hibernate? Hibernate 4 Example with Eclipse How to learn Hibernate? What is Hibernate Framework? hibernate faq 15/03/14 hibernate 15/03/2014 Hibernate Criteria Wildcard how to add mulitiple projections this is a hibernate question this is a hibernate question this is a hibernate question how to writw connection pool coding Hibernate 4.3 and JPA 2.1 support How to create Hibernate session factory name? Can you provide me Hibernate configuration tutorial? I want to build sessionfactory in hibernate 4. Need help. I want to learn Hibernate tutorial quickly How to create sessionfactory in Hibernate 4.1.1? How to create sessionfactory in Hibernate 4.1? Hibernate 4.3.0.Final get session How to learn hibernate in 24 hours? hibernate 4.3.0 I want to know how can I create sessionfactory in hibernate 4 (latest version) standard serviceregistrybuilder example

Ads

 
Advertisement null

Ads