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…
[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.
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)
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/:?]
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.
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.
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
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.
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.
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.
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.
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…)
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
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
<!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
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