Issues
- LocalXmlResourceResolver does not resolve dtd URLs that use https schemeHHH-16892Resolved issue: HHH-16892Yoann Rodière
- @NotFound(Ignore) defaults to eager loadingHHH-15545Resolved issue: HHH-15545Gavin King
- Lazy loading is not working when @NotFound IGNORE is usedHHH-15530Resolved issue: HHH-15530
- FETCH LEFT JOIN is not UNPROXY enentity anymoreHHH-15337Resolved issue: HHH-15337
- JPA Query not working in hibernate >=5.6.6 - org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select listHHH-15304
- Query Fails in case of a Restriction on a manyToOne-Attribute which has inheritance and @NotFound Annotation (>= 5.6.6)HHH-15299
- testingHHH-15296Resolved issue: HHH-15296
- Testing new featuresHHH-15295Resolved issue: HHH-15295
- LazyInitializationException caused by @NotFound and Session.evict() (caused by HHH-15060?)HHH-15272
- SchemaExport.execute does not add the configured schema to commentsHHH-15265Resolved issue: HHH-15265Yoann Rodière
- Batching is broken for Hibernate versions >= 5.6.1.FinalHHH-15254Resolved issue: HHH-15254
- SchemaExport.execute does not replace the ${schema}-placeholder in HBM database-object with configured schemaHHH-15212Resolved issue: HHH-15212Yoann Rodière
- Spring Data JPA `startsWith()` not work with HibernateHHH-15199Resolved issue: HHH-15199
- CriteriaQuery - IllegalArgumentException when parameter name clashes with generated parameter nameHHH-15185
- ContainsIgnoreCase JPA queries stop working after upgrade from hibernate core 5.6.4 to 5.6.7HHH-15172Resolved issue: HHH-15172
- Error with parameters in "startsWith" queryHHH-15158Resolved issue: HHH-15158
- hibernate-jpamodelgen-jakarta annotation processor ignores jakarta.* annotationsHHH-15147Resolved issue: HHH-15147Yoann Rodière
- CriteriaQuery with Like predicate fails when repeated with java.lang.IllegalArgumentException: Parameter value [] did not match expected type [java.lang.String (n/a)]HHH-15142Resolved issue: HHH-15142Andrea Boriero
18 of 18
LocalXmlResourceResolver does not resolve dtd URLs that use https scheme
Fixed
Description
Attachments
2
Created July 5, 2023 at 3:24 AM
Updated July 20, 2023 at 6:48 PM
Resolved July 7, 2023 at 11:06 AM
Activity
Yoann RodièreJuly 5, 2023 at 7:08 AMEdited
This does look odd. The git history is a bit hard to follow due to some major refactorings, though… So I can’t tell why it is that way.
Thanks for reporting, I’ll have a look.
Background
As per the following recommendation, we had updated all our hibernate mapping files to refer dtd files using https scheme
The markup declarations contained or pointed to by the document type declaration must be well-formed - Hibernate ORM - Hibernate
i,e we had updated existing dtd urls from
http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd
to
https://hibernate.org/dtd/hibernate-mapping-3.0.dtd
Also, we had upgraded hibernate version to version 5.6.6 (which has a fix for HHH-15094)
Problem
Hibernate does not resolve dtd files locally when using https scheme,
But, it resolves the dtd files locally when using http scheme
Analysis
Following is a snippet of code from LocalXmlResourceResolver,
When HTTP scheme is used, Hibernate uses startsWith to compare with the identifierBase,
But, when HTTPS scheme is used, Hibernate uses matches to compare with the identiferBase (which fails due to the presence of version at the end of systemId)
For example,
Consider a hibernate mapping file with the following DOCTYPE (changed as per above recommendation)
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd">
In the LocalXmlResourceResolver, The condition which checks whether to return local resource, fails and returns false when https scheme is used
i,e
if ( systemId.startsWith( httpBase )
|| systemId.matches( httpsBase ) ) {
return true;
}
checks as follows
"https://hibernate.org/dtd/hibernate-mapping-3.0.dtd".matches(
"hibernate.org/dtd/hibernate-mapping"
)which returns false
Proposed solution
Change systemId.matches() to either systemId.startsWith() or systemId.contains()
Test
In the attached unit test, we can find that the test case that tries to resolve dtd file using HTTPS scheme fails, whereas the the test case that tries to resolve dtd file using HTTP scheme succeeds