Java “线程中的异常”;“主要”;org.hibernate.hibernateeexception:无法分析配置:hibernate.cfg.xml
我得到以下例外情况:Java “线程中的异常”;“主要”;org.hibernate.hibernateeexception:无法分析配置:hibernate.cfg.xml,java,hibernate,Java,Hibernate,我得到以下例外情况: 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.config
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
整个堆栈跟踪
这是我的配置文件:
<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>
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:devt2x
斯科特
老虎
org.hibernate.dialogue.oracle9dialogue
真的
嵌套异常表示解析器试图与某处建立网络连接,但失败。无法确定它试图连接到什么、为什么以及连接失败的原因。然而,我猜:
- 它试图获取DTD或XML模式,并且
- 它失败是因为:
- 您使用了错误的URL(在配置文件中)
- 承载DTD或架构的服务器已关闭,或
- 某些防火墙正在阻止正在进行的连接
(3) 同时检查dtd我通过删除dtd前面的空格解决了这个问题。dtd前面不应该有空格。你能显示你的hibernate.cfg.xml吗?你也应该在这里发布你的hibernate.cfg.xml文件的内容。这是我的hibernate.cfg.xml文件你在文件中没有任何dtd或模式URL,所以这一定是另外两个原因之一。尝试在启动日志以进行调试的情况下运行,看看这是否为您提供了任何线索。或者,在安装了调试器的情况下启动应用程序/web容器,在
doConfigure
方法上设置断点,并尝试找出它试图下载的内容(以及原因)。这似乎并不相关。XML文件没有DTD。是的,它有DTD。您可以从OP自己给出的答案中看到,而且这也是SAX解析器中存在连接超时的唯一原因。非常感谢。救了我一天!