开发者

Error in hibernate.cfg.xml

In my hibernate.cfg.xml I receive the following error :

Referenced file contains errors (http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd). For more information, right click on the message in the Problems View and select "Show Details..."

When I view "show details" I receive this error :

The markup declarations contained or pointed to by the document type declaration must be well-formed

Here is my hibernate.cfg.xml :

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="connection.url">jdbc:mysql://localhost/test</property>
    <property name="connection.username">root</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="connection.password">root</property>
    <property name="hibernate.hbm2ddl.auto">update</property> 
 <property name="transaction.factory_class">开发者_开发知识库org.hibernate.transaction.JDBCTransactionFactory</property>
    <!--  thread is the short name for
      org.hibernate.context.ThreadLocalSessionContext
      and let Hibernate bind the session automatically to the thread
    -->
    <property name="current_session_context_class">thread</property>
    <!-- this will show us all sql statements -->
    <property name="hibernate.show_sql">true</property>

    <mapping class="com.event.model.Event"/>

</session-factory>
</hibernate-configuration>


The indicated answer is NOT the correct answer! The Jboss servers most certainly aren't down.

The URL being used in the OPs question is what is listed on the Hibernate docs site and yet redirects to http://ww1.sourceforge.com which is an advertising page holder - go figure.

The url I found with the valid DTD is at:

http://www.jboss.org/dtd/hibernate/hibernate-configuration-3.0.dtd

Hope this helps someone with this problem.


If you are willing to work offline add a new user entry on your xml catalog to map the URI to a local copy of your DTD.

Window -> Preferences -> + XML -> XML Catalog.  

Using the XML Catalog
XML Catalog Tutorial


I had the same issue. Found a solution

replace all Code: "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" for "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"


Change your doctype to this :

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


I have the same Issue. So, my fix was very simple. I made some modifications to the file. After that I reverted them and the issue was fixed. By Nithin.


It's quite simple: the URL http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd currently doesn't work because jboss's servers are down.


Like he said, http://www.jboss.org/dtd/hibernate/hibernate-configuration-3.0.dtd Replace it with this url. The error is gone now. Even after adding the property attribute. Thanks!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜