Could not parse configuration: /hibernate.cfg.xml Caused by: org.dom4j.DocumentException: Connection refused


If you every run into the below,

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
 at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1500)
 at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
 at org.hibernate.cfg.Configuration.configure(Configuration.java:1420)
 at org.hibernate.tutorial.hbm.NativeApiIllustrationTest.setUp(NativeApiIllustrationTest.java:47)
 at junit.framework.TestCase.runBare(TestCase.java:132)
 at junit.framework.TestResult$1.protect(TestResult.java:110)
 at junit.framework.TestResult.runProtected(TestResult.java:128)
 at junit.framework.TestResult.run(TestResult.java:113)
 at junit.framework.TestCase.run(TestCase.java:124)
 at junit.framework.TestSuite.runTest(TestSuite.java:243)
 at junit.framework.TestSuite.run(TestSuite.java:238)
 at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect
 at org.dom4j.io.SAXReader.read(SAXReader.java:484)
 at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1490)
 ... 17 more

it means that the XML parser is having a problem trying to access your DTD definition. So first thing to do is to see if you can browse the url for it directly and also check your proxy settings. In my case, I changed it

from
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

to

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

I think you can also try using "http://www.jboss.org/dtd/hibernate/hibernate-configuration-3.0.dtd". It seems like hibernate.org fwds to the jboss location anyways.

(as of today....unless the urls change again)

Comments (1)

Thank you 100x for this. :)

Post a Comment