Improve subframework launch
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentNamespace.java
index 429b759fc03a4c6e4ff9fe5c20afd6f5bce12caa..fe334cb5b9d5430aa7c28fddc6e438b2c120cc65 100644 (file)
@@ -1,6 +1,7 @@
 package org.argeo.cms.acr;
 
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.Objects;
 
@@ -52,7 +53,13 @@ public enum CmsContentNamespace implements ContentNamespace {
                Objects.requireNonNull(namespace);
                this.namespace = namespace;
                if (resourceFileName != null) {
-                       resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
+                       // resource = getClass().getResource(RESOURCE_BASE + resourceFileName);
+                       try {
+                               // FIXME workaround when in nested OSGi frameworks
+                               resource = URI.create("platform:/plugin/org.argeo.cms" + RESOURCE_BASE + resourceFileName).toURL();
+                       } catch (MalformedURLException e) {
+                               throw new IllegalArgumentException("Cannot convert " + resourceFileName + " to URL");
+                       }
                        Objects.requireNonNull(resource);
                }
                if (publicUrl != null)