3

I created a small project in my company today. In Hibernate Perspective I try to add new configuration so that I can create entities easily from db tables which have several columns. But when I select my project, it gives me org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml

Complete Stack Trace -

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
    at org.jboss.tools.hibernate.proxy.ConfigurationProxy.configure(ConfigurationProxy.java:100)
    at org.hibernate.console.ConfigurationFactory.loadConfigurationXML(ConfigurationFactory.java:355)
    at org.hibernate.console.ConfigurationFactory.configureStandardConfiguration(ConfigurationFactory.java:279)
    at org.hibernate.console.ConfigurationFactory.buildConfiguration(ConfigurationFactory.java:174)
    at org.hibernate.console.ConfigurationFactory.createConfiguration(ConfigurationFactory.java:96)
    at org.hibernate.eclipse.console.common.HibernateExtension$5.execute(HibernateExtension.java:166)
    at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
    at org.hibernate.eclipse.console.common.HibernateExtension.execute(HibernateExtension.java:189)
    at org.hibernate.eclipse.console.common.HibernateExtension.buildWith(HibernateExtension.java:163)
    at org.hibernate.eclipse.console.common.HibernateExtension.build(HibernateExtension.java:134)
    at org.hibernate.console.ConsoleConfiguration.build(ConsoleConfiguration.java:189)
    at org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter.getChildren(ConsoleConfigurationWorkbenchAdapter.java:43)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:98)
    at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:104)
    at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:238)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
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:2238)
    ... 18 more

Even after using many hibernate versions and changing DTD many times I am not able to figure out the issue. Can someone please help me on this. It is a simple maven project and .cfg.xml file is placed into src/main/java

I even downloaded a simple project from this url http://www.mkyong.com/hibernate/maven-3-hibernate-3-6-oracle-11g-example-xml-mapping/ and then tried to add new configuration but again got the same problem. I just changed the respective DB credentials I had. They are correct since using the same jdbc url I have created a new DB connection in Data Source Explorer successfully. Kindly help.

Internet is working fine in my company.

Community
  • 1
  • 1
abhihello123
  • 1,668
  • 1
  • 22
  • 38

2 Answers2

2

Try changing the DTD definition in the hibernate.cfg.xml from:

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

to:

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

This way the XML parser will not attempt to load the DTD file from the Internet, but it will try to load it from the Hibernate jars.

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • No it gives same error Classpath]: Could not parse configuration:C:\Workspaces\excelws\HibernateExample\src\main\resources\hibernate.cfg.xml When core is selected. And [Classpath]: Could not load AnnotationConfiguration when Annotations is selected. – abhihello123 Jul 02 '15 at 07:42
1

You can open the config file throw web browser(firefox), to check whether your config file is OK. If it has some thing wrong, the browser will show it out to you. I refer to (http://blog.csdn.net/caixiexin/article/details/7024623).

simple
  • 43
  • 3