• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in hibernate programme

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at com.javatpoint.mypackage.StoreData.main(StoreData.java:13)
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2 more

"

hibernate.cfg.xml:-

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

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

<session-factory>
<property name="hbm2ddl.auto">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"/>
</session-factory>


Please help me for what this problem occurs and how to resolve it.
</hibernate-configuration>
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Chinmoy Nag
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 -

antlr-2.7.6.jar
asm.jar
asm-attrs.jar
c3p0-0.9.1.jar
cglib-2.1.3.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
ejb3-persistence.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-validator.jar
jdbc2_0-stdext.jar
jta.jar
log4j-1.2.11.jar
xerces-2.6.2.jar
ojdbc14.jar


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
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to grab the distribution again. It should be finding it see the documentation here

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#tutorial-firstapp-mapping

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:
http://sourceforge.net/projects/hibernate/files/hibernate3/3.6.10.Final/
 
Chinmoy Nag
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing.
The code of StoreData class is as below -

 
Ranch Hand
Posts: 112
Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swetha :

Could you please specify the six jar files I need to add.
It will be very helpful.
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
2)........\required\commons-collections-3.1.jar
3).........\required\dom4j-1.6.1.jar
4).........\required\javassist-3.12.0.GA.jar
5)..........\required\jta-1.1.jar
6)...........\required\slf4j-api-1.6.1.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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic