File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Problem in hibernate programme Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem in hibernate programme" Watch "Problem in hibernate programme" New topic

Problem in hibernate programme

Chinmoy Nag

Joined: Sep 20, 2012
Posts: 5

I am new in hibernate, just in the learning phase.
I am using eclipse indigo, hibernate, oracle 10g.
In my first programme got from internet during run the programme the below error I am getting -

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(
at org.hibernate.cfg.Configuration.configure(
at com.javatpoint.mypackage.StoreData.main(
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.hibernate.cfg.Configuration.doConfigure(
... 2 more



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

<!-- Generated by MyEclipse Hibernate Tools. -->

<property name="">update</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="connection.url">jdbc:oracle:thin:@***.**.**.**:****:<db name></property>
<property name="connection.username"><username></property>
<property name="connection.password"><password></property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<mapping resource="employee.hbm.xml"/>

Please help me for what this problem occurs and how to resolve it.
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

Welcome to the Ranch! In the future please UseCodeTags when posting code or configuration.

It is looking for your DTD in the jar and not finding it. It will then look for it online and you are probably behind a proxy or something. Try changing it like below:

What version of hibernate are you using?

[How To Ask Questions][Read before you PM me]
Chinmoy Nag

Joined: Sep 20, 2012
Posts: 5
Thanks for reply.
I have tried your suggested way, but not get resolved.
Actually I am trying to access a remote database to which I have to connect through VPN client. After get connected through VPN client my internet connection is not working. I think for run my code internet connection is needed.
Please corrrect, if it is not right.

I created a simple java project and added jar files in eclipse -


By the first 3 lines of code in hibernate.cfg.xml, I can say that I am using hibernate 3.0 version.

Please assist me.
Bill Gorder

Joined: Mar 07, 2010
Posts: 1682

You might want to grab the distribution again. It should be finding it see the documentation here

Hibernate will not load the DTD file from the web, but first look it up from the classpath of the application. The DTD file is included in hibernate-core.jar (it is also included in the hibernate3.jar, if using the distribution bundle).

The fact that it appears to be trying to go to the web means its not finding it in the JAR. It should be there. Are you still getting the same exception after applying the change I mentioned or is it a different one? You also did not post the full stack trace.

You can re-download the distribution from here:
Chinmoy Nag

Joined: Sep 20, 2012
Posts: 5
Thanks for the good help.

But I am getting the same error -

I need to see an example of simple hibernate program that is running fine.
Chinmoy Nag

Joined: Sep 20, 2012
Posts: 5
One more thing.
The code of StoreData class is as below -

Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112

@Chinmoy Nag.

try to add all the six JAR files of required folder of Hibernate 3(as you are using that version), i think some JAR files are missing like "...\required\javassist-3.12.0.GA.jar" etc. I am not sure that this might be the solution but please try to add all six JAR files also copy and paste <!DOCTYPE..> element from predefined examples instead of manual typing according to the version you are using.

Chinmoy Nag

Joined: Sep 20, 2012
Posts: 5
Swetha :

Could you please specify the six jar files I need to add.
It will be very helpful.
Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112

@Chinmoy Nag:
some of the JAR files you have already added .but anyways I am listing. But please check because I am not sure this could rectify the problem,expecting..

please try to add the following JAR files (of required folder of Hibernate 3):

1) ..\hibernate-3.6.5.Final-src\lib\required\antlr-2.7.6.jar

Also please add the following JAR file "..\hibernate-3.6.5.Final-src\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar" from "jpa" folder of Hibernate 3
.. please verify the "required"and "jpa" folder you can find all the above JAR files and try to add them.
I agree. Here's the link:
subject: Problem in hibernate programme
jQuery in Action, 3rd edition