wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes problem parsing configuration /  hibernate.cfg.xml 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 parsing configuration /  hibernate.cfg.xml" Watch "problem parsing configuration /  hibernate.cfg.xml" New topic
Author

problem parsing configuration / hibernate.cfg.xml

samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
hi all
I have just starte learning Hibernate. Can anyone plzzzzzz tell me what exactly is the problem with my code
following is my hibernate.cfg.xml file
***********************************************
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="connection.driver">com.mysql.jdbc.Driver</property>
<property name="dialect">net.sf.hibernate.dialect.MySqlDialect</property>
<property name="url">jdbc:mysql://localhost/products</property>
<mapping resource="EventManager.hbm.xml"/>

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

***********************************************
and this is the error log file
**************************************************

2006-06-23 14:28:03,005: [INFO ] [main] net.sf.hibernate.cfg.Environment.<clinit>() - Hibernate 2.1 final
2006-06-23 14:28:03,035: [INFO ] [main] net.sf.hibernate.cfg.Environment.<clinit>() - loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
2006-06-23 14:28:03,035: [INFO ] [main] net.sf.hibernate.cfg.Environment.<clinit>() - using CGLIB reflection optimizer
2006-06-23 14:28:03,045: [INFO ] [main] net.sf.hibernate.cfg.Configuration.configure() - configuring from resource: /hibernate.cfg.xml
2006-06-23 14:28:03,045: [INFO ] [main] net.sf.hibernate.cfg.Configuration.getConfigurationInputStream() - Configuration resource: /hibernate.cfg.xml
2006-06-23 14:28:21,169: [ERROR] [main] net.sf.hibernate.cfg.Configuration.doConfigure() - problem parsing configuration/hibernate.cfg.xml
org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:888)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:832)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:818)
at src.events.EventManager.main(Unknown Source)
Nested exception:
java.net.UnknownHostException: hibernate.sourceforge.net
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.Socket.connect(Socket.java:516)
at java.net.Socket.connect(Socket.java:466)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:365)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:477)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:214)
at sun.net.www.http.HttpClient.New(HttpClient.java:287)
at sun.net.www.http.HttpClient.New(HttpClient.java:299)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:795)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:747)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:672)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:916)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:888)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:832)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:818)
at src.events.EventManager.main(Unknown Source)
*****************************************************************************
I have already kept all Hibernate.cfg.xml and EventManager.hbm.xml files in the class path and I am using MySql DataBase.

Thanks in advance......

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Nested exception:
java.net.UnknownHostException: hibernate.sourceforge.net

Looks like there may be a problem with your DOCTYPE definition. Your application is having trouble finding hibernate.sourceforge.net, which is odd, since that is a valid host. You might change your DOCTYPE to reference the DTD contained in Hibernate.jar (i.e. from PUBLIC to SYSTEM) so it won't try to look things up remotely.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
hi Paul,
thanks for ur kind help,,,,As u said ...my DOCTYPE is already public and is refering to HIbernate3.jar
This is what the defination of DOCTYPE


<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


Is there anything wrong with it..??
DO I need to do something else??
Please let me know
Thnks for ur time
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


As u said ...my DOCTYPE is ... refering to HIbernate3.jar

No its not. Your DOCTYPE definition refers to a DTD that is on hibernate.sourceforge.net. Now that DTD exists (I can browse it via Firefox) but your application cannot access it. The purpose of the doctype element is to link to a DTD. It can do this three ways: either define the DTD in the XML file where it is declared, or link to a DTD on the local machine like this:

or link to a public dtd which is looked up from some public place, e.g.

So your doctype definition is not refering to the DTD in Hibernate3.jar. I can't guess why your applciation cannot access the public DTD, but you can change it to refer to the dtd in the jar file to workaround the problem.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yeah, what Paul was saying. Maybe the reason you are getting it is because you local machine doesn't have internet access connection at the time you are running this, so it can't access the internet DTD. So by doing what Paul says, you are taking Internet Access out of the equation.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
yeahh...what Paul said was rt....I did the configuration to the local system and it works well....
Thanks for the valuable guidance Paul ...
Regards
Samir
samir ware
Ranch Hand

Joined: Jul 27, 2005
Posts: 192
I should say thanks to Mark also for the guideline.
Mark ...thanks for the help once again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: problem parsing configuration / hibernate.cfg.xml