Spring Boot 2.0 and orm.xml: Duplicate XML entry

Description

Spring Boot 2.0 builds a fat jar and the orm.xml is stored in the jar file under

/BOOT-INF/classes/META-INF/orm.xml

This leads hibernate to load the orm.xml twice. See https://github.com/spring-projects/spring-boot/issues/10363 for another case, with an easy to reproduce test.

Details:
The Persistence unit is as follows

The scanner finds the orm in the jar file, but the logic inside `org.hibernate.boot.model.process.internal.ScanningCoordinator#applyScanResultsToManagedResources` leads to the file being loaded a second time, causing this exception.

This can be fixed with a custom scanner:

Environment

None

Activity

Show:
Emmanuel Bernard
July 31, 2018, 4:04 PM

As I mentioned in the Hibernate dev mailing list. I think the spec says that a provider must include META-INF/orm.xml by default. The fact that the PersistenceUnit implementor is adding it is the reason for the failure.

We could try and be nice a detect that someone tries to add the file in parallel but we haven't guarded against PersistenceUnit implementor fuzzy behaviors as there is so few of them in existence.

Assignee

Unassigned

Reporter

Jonas von Andrian

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major