[embjopr-commits] EMBJOPR SVN: r991 - branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Mon Oct 25 13:52:05 EDT 2010


Author: ips
Date: 2010-10-25 13:52:04 -0400 (Mon, 25 Oct 2010)
New Revision: 991

Modified:
   branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java
Log:
fix bug that caused plugins to fail to deploy if the plugin jars were symlinks (https://jira.jboss.org/browse/JBPAPP-5276 / https://jira.jboss.org/browse/EMBJOPR-342)

Modified: branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java
===================================================================
--- branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java	2010-10-25 17:34:31 UTC (rev 990)
+++ branches/AdminConsole_EAP_5_1/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java	2010-10-25 17:52:04 UTC (rev 991)
@@ -1,6 +1,6 @@
 /*
  * Embedded Jopr Project
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.Collection;
 import java.util.Set;
@@ -237,13 +238,41 @@
         {
             if (pluginString.endsWith(".jar"))
             {
-                URL pluginUrl = servletContext.getResource(pluginString);
+                URL pluginUrl = getResource(pluginString);
                 pluginFinder.addUrl(pluginUrl);
             }
         }
         return pluginFinder;
     }
 
+    private static URL getResource(String resourcePath) {
+        ServletContext servletContext = ServletLifecycle.getServletContext();
+        // NOTE: We use getRealPath() rather than getResource(), because getResource() returns null if the
+        //       plugin jar is a symlink, which will be the case for RPM-based EAP installs. However, we fall back
+        //       to getResource() if getRealPath() returns null, which might be the case if the admin console WAR
+        //       was deployed as a file, rather than a directory.
+        String filePath = servletContext.getRealPath(resourcePath);
+        URL url;
+        try {
+            if (filePath != null) {
+                File file = new File(filePath);
+                URI uri = file.toURI();
+                url = uri.toURL();
+            } else {
+                url = servletContext.getResource(resourcePath);
+                if (url == null) {
+                    throw new IllegalStateException("Failed to convert plugin jar resource path [" + resourcePath
+                        + "] to URL.");
+                }
+            }
+        }
+        catch (MalformedURLException e) {
+            throw new IllegalStateException("Failed to convert plugin jar resource path [" + resourcePath
+                + "] to URL.", e);
+        }
+        return url;
+    }
+
     private static void configureMockScenarioLoader()
     {
         LOG.trace("Configuring Mock Scenario Loader...");



More information about the embjopr-commits mailing list