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

Hi! We are experiencing an issue when running hbm2java this morning. Nothing changed, the error is saying it cannot read the doctype. Is there something wrong with the .dtd file temporarily? We can reach the file so it’s there…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Error:

[DEBUG] trying to resolve system-id [http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd]
[ERROR] Error parsing XML: file:/Y:/code/workspaces/src/main/java/hibernate.cfg.xml(1) The markup declarations contained or pointed to by the document type declaration must be well-formed.

Additional error tracing:

Caused by: org.dom4j.DocumentException: Error on line 1 of document http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd : The markup declarations contained or pointed to by the document type declaration must be well-formed. Nested exception: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at org.dom4j.io.SAXReader.read (SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure (Configuration.java:1518)
at org.hibernate.cfg.Configuration.configure (Configuration.java:1477)

I have a temporary fix:

We changed the dtd url to http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd and it works again.

1 Like

Look like something similar brought us down as well. The DTD that is was published on Febuary 22nd looks to be causing

Caused by: org.hibernate.boot.InvalidMappingException: Could not parse mapping document: null (INPUT_STREAM)
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:46) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:38) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
at org.hibernate.boot.spi.XmlMappingBinderAccess.bind(XmlMappingBinderAccess.java:94) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
at org.hibernate.boot.MetadataSources.addInputStream(MetadataSources.java:382) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:475) ~[hibernate-core-5.4.2.Final.jar:5.4.2.Final]
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:515) ~[spring-orm-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at com.connexin.op.application.DataSourceConfig.medicalSessionFactory(DataSourceConfig.java:106) ~[classes/:?]

Using the sourceforge version: http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd got us back up for now. But we will have to update a couple hundred clients if the main DTD isn’t updated again.

Hi!, everyone.
We have the same problem as hibscott.
I have changed the URL as indicated by hibscott in the temporary fix but it doesn’t work.

The error is as follows:

Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,3]
Message: The marker declarations that are included or pointed to by the document type declaration must be in the correct format.
	at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)
	at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:276)
	at org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:118)
	... 19 more

If I had to guess, I would say your XML parser doesn’t support redirections? Or maybe HTTPS?

Try using this URL for the DTD: https://hibernate.org/dtd/hibernate-configuration-3.0.dtd. That’s the canonical one and the one everyone should be using, all other URLs are legacy.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "https://hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Thank you very much, yrodiere, this worked like a charm.
So the http:// support has been discontinued?
Ok, we will have to deploy new versions of the application to change the protocol.
I’m worried that the online DTD will suffer some problem in the future like a DTD domain crash due to DDos attack or an unauthorized access that replaces the original with a fake DTD, many applications in the world would fall like a house of cards.

I would also recommend some kind of advance warning when such changes are going to be made so as not to cause panic.

Thanks for the fix!

1 Like

It has not. IT seems to have added an automatic redirection from HTTP to HTTPS, that’s all. And they did it without warning the Hibernate team :confused:

Fake DTDs are less of a problem if you use HTTPS, but network failures are for sure. Which is why it’s better to host a copy of the DTD locally. Or to disable DTD validation on production environmnents, but I’m not sure how to do that.

We tried in the past. There was panic anyway :slight_smile:

Hello, thanks for all the insights.
Is there any chance for the IT change to be rollbacked.
We have large production systems down at the moment because of this change.

I’ll try, but this will take time, maybe days. You’re better off updating your applications to use https://hibernate.org/dtd/hibernate-configuration-3.0.dtd.

2 Likes

Could all the people who have the problem confirm if things are working by changing the URL specifically to: https://hibernate.org/dtd/hibernate-configuration-3.0.dtd?

I.e. not the http sourceforge one that some of you declared using but the canonical https URL at hibernate.org.

1 Like

Also, please give us the version of Hibernate ORM you’re using, and details about your environment (JVM, Spring, WildFly, … and which version) so we can try to reproduce the problem.

1 Like

If you can reproduce the problem and ends up on this thread, please signal yourself and provide the following information:

  • OS and version
  • JDK version
  • Spring/WildFly/EAP/… version
  • Hibernate ORM version
  • the structure of your Hibernate ORM config file (we don’t need the name of the entities but the general structure of it with the DTDs, potential references to other files…)

Of course, if you can, providing a reproducer (for example based on hibernate-test-case-templates/orm/hibernate-orm-5 at main · hibernate/hibernate-test-case-templates · GitHub ) would be of tremendous help.

1 Like

Hi, yrodiere.

I tried to configure locally the hibernate-configuration-3.0.dtd file inside the /resources folder of a Maven project.

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration SYSTEM
    "classpath://org/hibernate/hibernate-configuration-3.0.dtd">

I get the error back:

unknown protocol: classpath

I think this is the best option of all so as not to depend on whether or not there is connectivity to the DTD file.
Thank you for your help.

Regards,
Álvaro.

Honestly I can’t reproduce the problem at the moment, so it’s a bit hard to come up with a workaround.

Maybe you can help by giving more info? See below.

1 Like

Hello,
To answer with our current usecase:
with this URL it fails
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

with this one it works
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

OS: Windows 11, Google cloud, On Prem… (Not related to OS)
JDK: OpenJDK8, Amazon Corretto 11
SpringBoot, old application… (Not related)
Hibernate-Version: 3.1.3 (at least)
Sample of hmb.xml

 <?xml version='1.0' encoding='utf-8'?>
 <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
 
 <hibernate-mapping>
     <class name="NAME" table="table_name" schema="schema">
         <id name="Id" column="column_id">
            <generator class="native" />
        </id>
         <many-to-one name="child" class="Child" column="child_id" not-null="true" fetch="join" lazy="false"/>
       
         <property name="property1" column="column_property1"/>
         <property name="property1" column="column_property2"/>
       
    </class>
</hibernate-mapping>

Sample of error message:

2022-02-24 16:21:17.267 ERROR xxxxxx:61 - Error parsing XML: XML InputStream(1) The markup declarations contained or pointed to by the document type declaration must be well-formed.
2022-02-24 16:21:17.272 ERROR xxxxxxx:52 - server error org.hibernate.MappingException: Could not read mappings from resource:  xxxxxx.hbm.xml

@Ludo can you try with these URLs:

  • https://hibernate.org/dtd/hibernate-configuration-3.0.dtd for config
  • https://hibernate.org/dtd/hibernate-mapping-3.0.dtd for mapping
    ?
1 Like

hi
I tried to change with this

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

And I also have updated the config file with:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "https://hibernate.org/dtd/hibernate-configuration-3.0.dtd" >

But I getting the error
2022-02-24 17:01:59.990 INFO XXXXXX:497 - Reading mappings from resource: com/zdirect/core/XXXXX.hbm.xml
2022-02-24 17:02:01.222 ERROR XXXXXX:52 - server error org.hibernate.MappingException: Could not read mappings from resource: XXXXX.hbm.xml

Hello, everyone.

For those of you having problems with https://, you can try removing www. from the URL and it should work as well.

IT seems to have removed the redirect from the subdomain www.hibernate.org to hibernate.org.

Tested with:

  • WildFly 9.0.2
  • Spring Framework 4.x
  • hibernate-core-5.0.0.jar
  • Java 8

Regards,

1 Like

Ok but in my case I would like to not change anything in my code as it will imply a lot of re-deployment in production.
If we can make the http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd work as before it will save a lot of time.
If not then we will patch :slight_smile: