HibernateException:无法解析配置

时间:2013-03-14 07:47:45

标签: eclipse hibernate exception-handling

我的hibernate有问题

追踪:

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1586)
    at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1212)
    at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:107)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
    at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1194)
    at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:107)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
    at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1188)
    at hibernate.filling.HibernateFill.fillDetail(HibernateFill.java:22)
    at scanningDirective.ScanningTimer$1.run(ScanningTimer.java:57)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)
Caused by: org.dom4j.DocumentException: www.hibernate.org Nested exception: www.hibernate.org
    at org.dom4j.io.SAXReader.read(SAXReader.java:484)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1576)
    ... 11 more

实际上我不明白为什么它不起作用,因为前一段时间它运行良好,并且在我离开项目一段时间后,在这一刻我可以安装一些插件到eclips或其他任何东西,当然我明白代码不能神奇地改变。那么,你怎么看待这种行为的原因是什么?

对不起......我是怎么忘记的...... 这是Hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>

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

<hibernate-configuration>

    <session-factory>

        <!-- Database connection settings -->
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="connection.url">jdbc:postgresql://localhost:5432/mydb</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password">1</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">2</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>

        <!-- Names the annotated entity class -->
        <mapping class="documentElements.Header"/>
        <mapping class="documentElements.Detail"/>


    </session-factory>

</hibernate-configuration>

我改变后

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

为:

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

一切都开始了。我不明白为什么它第一次不起作用。 Mabe我需要重启项目...

0 个答案:

没有答案