@@ -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 *
0 commit comments