0

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>
2
  • can you show your hibernate.cfg.xml? Commented Dec 8, 2014 at 12:31
  • 3
    You should post the contents of your hibernate.cfg.xml file here as well. Commented Dec 8, 2014 at 12:33

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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.

2 Comments

this is my hibernate.cfg.xml file
You don't have any DTD or Schema URLs in the file, so it must be one of the other two reasons. Try running with logging cranked up to DEBUG to see if this gives you any clues. Alternatively, launch your application / web container with a debugger attached, set a break point on the doConfigure method, and try to figure out what it is trying to download (and why).
0

(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

2 Comments

This doesn't seem related. The XML file does not have a DTD.
Yes it does have a DTD. You can see in the answer that the OP himself has given, and furthermore it's the only reason why there could be a connection timeout in a SAX parser.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.