3

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>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • Possible existing solution:http://stackoverflow.com/questions/17114046/hibernate-error-possibly-with-dtd-declaration – Ajay Takur Jun 14 '16 at 14:01

7 Answers7

4

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.

Matt Keeble
  • 244
  • 3
  • 8
2

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"

Mohan Seth
  • 761
  • 2
  • 11
  • 20
2

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

jhurtado
  • 8,587
  • 1
  • 23
  • 34
2

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">
Joffrey Hernandez
  • 1,809
  • 3
  • 21
  • 39
iarik
  • 61
  • 2
1

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.

-1

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!!

Sheeba Nancy
  • 75
  • 1
  • 8
-1

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.

Alex Godofsky
  • 708
  • 4
  • 16
  • I'm a little confused, so should it work if my computer is not connected to this internet ? would'nt be able to confirm if the jboss servers are down or not? – blue-sky Jan 19 '11 at 18:16
  • yes correct jboss's server are down , alternate we can use – Prasad Giri Aug 20 '21 at 11:38