Author: ips
Date: 2010-10-25 13:34:31 -0400 (Mon, 25 Oct 2010)
New Revision: 990
Modified:
trunk/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 are symlinks
(
https://jira.jboss.org/browse/EMBJOPR-342)
Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java 2010-09-23
21:11:17 UTC (rev 989)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/BootstrapAction.java 2010-10-25
17:34:31 UTC (rev 990)
@@ -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;
@@ -262,11 +263,30 @@
private static URL getResource(String resourcePath) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
+ // 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 = externalContext.getRealPath(resourcePath);
+ URL url;
try {
- return externalContext.getResource(resourcePath);
- } catch (MalformedURLException e) {
- throw new IllegalStateException(e);
+ if (filePath != null) {
+ File file = new File(filePath);
+ URI uri = file.toURI();
+ url = uri.toURL();
+ } else {
+ url = externalContext.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()