@@ -15,6 +15,7 @@ import org.springframework.context.ResourceLoaderAware
1515import org.springframework.context.annotation.Bean
1616import org.springframework.core.io.DefaultResourceLoader
1717import org.springframework.core.io.Resource
18+ import org.springframework.core.io.UrlResource
1819import org.springframework.core.io.support.PathMatchingResourcePatternResolver
1920import org.springframework.core.io.support.ResourcePatternResolver
2021import org.springframework.core.type.classreading.CachingMetadataReaderFactory
@@ -213,23 +214,33 @@ class GrailsAutoConfiguration implements GrailsApplicationClass, ApplicationCont
213214 private static class ApplicationRelativeClassLoader extends URLClassLoader {
214215
215216 final URL rootResource
217+ final Class applicationClass
218+ final boolean jarDeployed
216219
217220 ApplicationRelativeClassLoader (Class applicationClass ) {
218221 super ([ IOUtils . findRootResource(applicationClass)] as URL [])
219222
220223 this . rootResource = getURLs()[0 ]
224+ this . applicationClass = applicationClass
221225 def urlStr = rootResource. toString()
226+ jarDeployed = urlStr. startsWith(" jar:" )
222227 try {
223228 def withoutBang = new URL (" ${ urlStr.substring(0, urlStr.length() - 2)} /" )
224229 addURL(withoutBang)
230+
225231 } catch (MalformedURLException e) {
226232 // ignore, running as a WAR
227233 }
228234 }
229235
230236 @Override
231237 Enumeration<URL > getResources (String name ) throws IOException {
232- return super . findResources(name)
238+ if (jarDeployed && name == ' ' ) {
239+ return applicationClass. getClassLoader(). getResources(name)
240+ }
241+ else {
242+ return super . findResources(name)
243+ }
233244 }
234245 }
235246
0 commit comments