Skip to content

Commit 68f9f81

Browse files
committed
Fix deploying with a slim war. Fixes #10090
1 parent a1cd33b commit 68f9f81

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

grails-bootstrap/src/main/groovy/grails/util/Environment.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public enum Environment {
125125
private static final String GRAILS_IMPLEMENTATION_TITLE = "Grails";
126126
private static final String GRAILS_VERSION;
127127
private static final boolean STANDALONE_DEPLOYED;
128+
private static final boolean WAR_DEPLOYED;
128129

129130
static {
130131
Package p = Environment.class.getPackage();
@@ -198,6 +199,23 @@ public enum Environment {
198199
else {
199200
STANDALONE_DEPLOYED = false;
200201
}
202+
203+
URL loadedLocation = Environment.class.getClassLoader().getResource(Metadata.FILE);
204+
if(loadedLocation != null ) {
205+
String path = loadedLocation.getPath();
206+
WAR_DEPLOYED = isWebPath(path);
207+
}
208+
else {
209+
210+
loadedLocation = Thread.currentThread().getContextClassLoader().getResource(Metadata.FILE);
211+
if(loadedLocation != null ) {
212+
String path = loadedLocation.getPath();
213+
WAR_DEPLOYED = isWebPath(path);
214+
}
215+
else {
216+
WAR_DEPLOYED = false;
217+
}
218+
}
201219
}
202220

203221
public static Throwable currentReloadError = null;
@@ -324,17 +342,17 @@ public static boolean isDevelopmentRun() {
324342
* @return true if is
325343
*/
326344
public static boolean isWarDeployed() {
327-
URL loadedLocation = Environment.class.getClassLoader().getResource(Metadata.FILE);
328-
if(loadedLocation != null && loadedLocation.getPath().contains("/WEB-INF/classes")) {
329-
return true;
330-
}
331-
// Workaround for weblogic who repacks files from 'classes' into a new jar under lib/
332-
if (loadedLocation != null && loadedLocation.getPath().contains("_wl_cls_gen.jar!/")) {
333-
return true;
345+
if(!isStandalone()) {
346+
return WAR_DEPLOYED;
334347
}
335348
return false;
336349
}
337350

351+
private static boolean isWebPath(String path) {
352+
// Workaround for weblogic who repacks files from 'classes' into a new jar under lib/
353+
return path.contains("/WEB-INF/classes") || path.contains("_wl_cls_gen.jar!/");
354+
}
355+
338356
/**
339357
* Whether the application has been executed standalone via static void main.
340358
*

grails-plugin-gsp/src/main/groovy/org/grails/plugins/web/GroovyPagesGrailsPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
174174
resourceLoader = groovyPageResourceLoader
175175
}
176176
if (deployed) {
177-
def defaultViews = getClass().classLoader.getResource('gsp/views.properties')
177+
Resource defaultViews = applicationContext?.getResource('gsp/views.properties')
178178
List<Resource> allViewsProperties = []
179179

180180
for(plugin in pluginManager?.allPlugins) {
@@ -188,7 +188,7 @@ class GroovyPagesGrailsPlugin extends Plugin {
188188
}
189189
}
190190
if(defaultViews != null) {
191-
allViewsProperties.add(new UrlResource(defaultViews))
191+
allViewsProperties.add(defaultViews)
192192
}
193193

194194
allViewsProperties = allViewsProperties?.findAll { Resource r ->

0 commit comments

Comments
 (0)