diff --git a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java index c618dfddbd61..2dde2a2cf071 100644 --- a/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java @@ -148,14 +148,19 @@ public boolean exists() { */ @Nullable protected URL resolveURL() { - if (this.clazz != null) { - return this.clazz.getResource(this.path); - } - else if (this.classLoader != null) { - return this.classLoader.getResource(this.path); + try { + if (this.clazz != null) { + return this.clazz.getResource(this.path); + } + else if (this.classLoader != null) { + return this.classLoader.getResource(this.path); + } + else { + return ClassLoader.getSystemResource(this.path); + } } - else { - return ClassLoader.getSystemResource(this.path); + catch (IllegalArgumentException ex) { + return null; } }