user3026516
user3026516

Reputation: 3

Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml

I am getting the following exception:

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.ClientForSave.main(ClientForSave.java:26)
    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

Entire stack trace

Here is my config file:

<hibernate-configuration> 
    <session-factory> 
       <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
       <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:devt2x</property>
       <property name="hibernate.connection.username">scott</property> 
       <property name="hibernate.connection.password">tiger</property> 
       <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
       <property name="show_sql">true</property> 
    </session-factory>
</hibernate-configuration>

Upvotes: 0

Views: 6664

Answers (4)

Gen
Gen

Reputation: 2540

I resolved this problem by deleting the spaces infront of dtd stating.There should not be a space infront of dtd.

Upvotes: 1

harish kumar
harish kumar

Reputation: 11

(1)Some times your Antivirus block to connect to URL to download DTD. So first disable your Antivirus and then run app . (2)It may be dialect error, you have to use dialect for same database . (3)and also check for dtd

Upvotes: 0

user3026516
user3026516

Reputation: 3

I was to able to solve my problem.The Problem was the dtd and the required jars did not match. I went to the url in dtd and downloaded the jars and its working now dtd in my hibernate.cfg.xml file

Upvotes: 1

Stephen C
Stephen C

Reputation: 718826

The nested exception says that the parser has attempted to make a network connection to somewhere, and that failed. What it was trying to connect to, and why, and why the connect failed cannot be established definitively. However, I'm guessing that:

  • it was attempting to fetch a DTD or XML schema, and

  • it failed because:

    • you used the wrong URL (in your config file)

    • the server hosting the DTD or schema was down, or

    • some firewall is blocking out-going connections.

Upvotes: 0

Related Questions