From 6fed3425437ab1736244a8d77005b4fa8fa3e57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Tue, 13 Sep 2022 10:07:02 +0200 Subject: [PATCH] Refine DefaultPersistenceUnitManager#determineDefaultPersistenceUnitRootUrl This commit refines the implementation to be more lenient when defaultPersistenceUnitRootLocation is equals to ORIGINAL_DEFAULT_PERSISTENCE_UNIT_ROOT_LOCATION and an IOException is thrown, which happens when running on native image. Closes gh-29137 --- .../jpa/persistenceunit/DefaultPersistenceUnitManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java index e4e1eaea60..bc19a2e1df 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java @@ -579,6 +579,10 @@ public class DefaultPersistenceUnitManager return (ResourceUtils.isJarURL(url) ? ResourceUtils.extractJarFileURL(url) : url); } catch (IOException ex) { + if (ORIGINAL_DEFAULT_PERSISTENCE_UNIT_ROOT_LOCATION.equals(this.defaultPersistenceUnitRootLocation)) { + logger.debug("Unable to resolve classpath root as persistence unit root URL"); + return null; + } throw new PersistenceException("Unable to resolve persistence unit root URL", ex); } }