Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Exception in thread "main" org.hibernate.HibernateException:
PostPosted: Tue Jun 19, 2012 4:12 am 

Joined: Tue Jun 19, 2012 3:42 am
Posts: 1

I am new to the Hiberante,I tried below hibernate program inorder persist a java object,But its throwing below exception,Please help me out..
Thanks in Advance..

Jun 19, 2012 1:37:46 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1.3
Jun 19, 2012 1:37:46 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jun 19, 2012 1:37:46 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jun 19, 2012 1:37:46 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jun 19, 2012 1:37:47 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jun 19, 2012 1:37:47 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1376)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at com.hbtest.spatil.HibernateTest.main(HibernateTest.java:32)
Caused by: org.dom4j.DocumentException: http://www.hibernate.org/hibernate-conf ... on-3.0.dtd Nested exception: http://www.hibernate.org/hibernate-conf ... on-3.0.dtd
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1366)
... 3 more
my hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</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>

<mapping class="org.hbr.spatil.UserDetails"/>
<!-- <mapping class="org.hbtest.spatil.HibernateTest"/> -->


My main class
package com.hbtest.spatil;

import javax.xml.parsers.SAXParserFactory;

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

import com.hbr.spatil.UserDetails;

public class HibernateTest {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
UserDetails user=new UserDetails();
user.setUserName("USER FIRST");

SessionFactory sessionfactory=new Configuration().configure().buildSessionFactory();
Session session=sessionfactory.openSession();


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.