Fix our current usage of "felix.fileinstall.dir" property
A while ago a code change was made to support having a custom directory for Felix. https://github.com/dotCMS/core/pull/3395/files
This property seems to be a felix property and not a dotcms specific property so parts of it seem to work because felix picks up the setting; however, other parts do not work properly. For example, this code is looking for osgi-extra and other files in the hardcoded location of "/WEB-INF/felix": https://github.com/dotCMS/core/blob/3.6.0/src/com/dotmarketing/util/OSGIUtil.java#L82-L132 OSGIUtil seems to be the only class in our repos that reference this property at all.
I have not personally tested it but based on customer experience and looking at this code, push publishing does not honor this setting because of hardcoded paths:
-
bundler: https://github.com/dotCMS/enterprise-2.x/blob/master-3.7/src/com/dotcms/enterprise/publishing/remote/bundler/OSGIBundler.java#L70-L74
-
handler: https://github.com/dotCMS/enterprise-2.x/blob/master-3.7/src/com/dotcms/enterprise/publishing/remote/handler/OSGIHandler.java#L52-L55
-
https://github.com/dotCMS/core/blob/3.6.0/dotCMS/html/portlet/ext/osgi/availablebundlesjson.jsp#L21
Undeploy code also uses hardcoded paths: https://github.com/dotCMS/core/blob/3.6.0/src/com/dotmarketing/portlets/osgi/AJAX/OSGIAJAX.java#L47-L48
Expected Behavior
If "felix.fileinstall.dir" is set, then the bundle, felix-cache, load, & undeployed directories should be located under this directory as this documentation indicates: http://dotcms.com/docs/latest/osgi-plugins
Current Behavior
Client trying to use this setting and push publish plugin gets a NullPointerException:
Error Publishing Bundle: null java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.dotcms.enterprise.publishing.remote.handler.OSGIHandler.handle(SourceFile:53)
at com.dotcms.publisher.receiver.BundlePublisher.process(BundlePublisher.java:197)
at com.dotcms.rest.PublishThread.run(PublishThread.java:41)
at java.lang.Thread.run(Thread.java:745)
https://my.dotcms.com/tickets/detail.dot?id=a47e88b6-339c-409e-acd3-8cf4a3b9ee2f
Known Workarounds
Don't use property - symlink the felix directory to the alternate location
Workaround is only viable for non Windows platforms. Configuring tomcat to allow links opens this security hole - https://dotcms.com/security/SI-43
agreed on windows. I assume it was a UNIX client. But as Will said and I did also the real fix is not this issue but the referenced issue
On Fri, Mar 31, 2017 at 8:46 AM Brent Griffin [email protected] wrote:
Workaround is only viable for non Windows platforms. Configuring tomcat to allow links opens this security hole - https://dotcms.com/security/SI-43
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dotCMS/core/issues/10370#issuecomment-290702450, or mute the thread https://github.com/notifications/unsubscribe-auth/ABfteMIQPh6D9sjvqCht46Hf3oe6kzoFks5rrPWlgaJpZM4LUc8e .
@danlaguna, getting there! One other thing, we need to make sure these changes work with the new $env variable configuration
You can try something like this: String felixPath = com.dotmarketing.util.Config.getStringProperty(“MY_FELIX_PROP”, “/path/default“);
On the dot-marketing-config.properties you can do MY_FELIX_PROP={env.felixPath}
felixPath could be a properties in your bash profile or you can use on MAC, import felixPath=something, in the same session you start up the tomcat.
Thanks, J
Based on local tests and support from Jonathan Sánchez, the support to fetch the property is correctly set. The variables that can be overwritten are: FELIX_BASE_PATH: base Felix folder FELIX_DEPLOY_PATH: deploy Felix path FELIX_UNDEPLOYED_PATH: undeploy Felix path
On the dotmarketing-config.properties file you can set either FELIX_BASE_PATH=/WEB-INF/felix FELIX_DEPLOY_PATH=/WEB-INF/felix/load FELIX_UNDEPLOYED_PATH=/WEB-INF/felix/undeployed or FELIX_BASE_PATH={env:felixBasePath} FELIX_DEPLOY_PATH={env:felixDeployPath} FELIX_UNDEPLOYED_PATH={env:felixUndeployPath} or even don't set anything and values will be fetch from basic configuration.
PR enterprise: https://github.com/dotCMS/enterprise-2.x/pull/458
There is another requirement - we need to respect theVELOCITY_FOLDER config property everywhere within the dotCMS system. Currently, our ActivatorUtil has this value hard coded. Here is a search of where we need to change this property to use what is configured in the config properties:

@danlaguna @danlaguna take a look at the above comment. You might want this in a new issue which is fine.
Hi Guys,
Below you will find results after QAing and testing this issue. Hope this helps! Sorry for such a long comment, just tried to be descriptive:
- If customizing properties via dotmarketing-config.properties file, Upload Plugin functionality failed when exercised from Dynamic-Plugins portlet under "Dev Tools -> Plugins": 1.1. Following are the values that were used for the now configurable properties:
FELIX_BASE_PATH=/WEB-INF/new-felix
FELIX_DEPLOY_PATH=/WEB-INF/new-felix/new-load
FELIX_UNDEPLOYED_PATH=/WEB-INF/new-felix/new-undeployed
1.2. Following is the exception that appeared upon clicking the Upload button:
java.io.FileNotFoundException: /Users/anibalgomez/Development/Workspace/dotCMS/4.1.0/tomcat8/webapps/ROOT/WEB-INF/new-felix/load/edu.msu.anr.osgi.viewtools.MapUtilsTool-1.0.2.jar (No such file or directory)
at java.io.FileOutputStream.open0(Native Method) ~[?:1.8.0_102]
at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[?:1.8.0_102]
at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[?:1.8.0_102]
at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[?:1.8.0_102]
at com.dotmarketing.portlets.osgi.AJAX.OSGIAJAX.add(OSGIAJAX.java:161) ~[dotcms_4.1.0_999999.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_102]
at com.dotmarketing.portlets.osgi.AJAX.OSGIBaseAJAX.service(OSGIBaseAJAX.java:52) [dotcms_4.1.0_999999.jar:?]
at com.dotmarketing.portlets.osgi.AJAX.OSGIAJAX.service(OSGIAJAX.java:24) [dotcms_4.1.0_999999.jar:?]
at com.dotmarketing.servlets.ajax.AjaxAction.doPost(AjaxAction.java:56) [dotcms_4.1.0_999999.jar:?]
at com.dotmarketing.servlets.ajax.AjaxDirectorServlet.service(AjaxDirectorServlet.java:42) [dotcms_4.1.0_999999.jar:?]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:?]
1.3. After a shallow code-review, it was noticed that "load" dir is still hard-coded in OSGIAJAX class. This might be the cause of the exception since code is trying to copy the JAR file to the "load" unexisting directory: https://github.com/dotCMS/core/blob/master/dotCMS/src/main/java/com/dotmarketing/portlets/osgi/AJAX/OSGIAJAX.java#L148
-
Even if properties were customized via dotmarketing-config.properties file (with values listed above), Upload Plugin functionality succeeded when manually copying the JAR file into default Felix load directory (ie. "/WEB-INF/felix/load"). I wonder if: 2.1. This should not be the case since Felix load directory was customized to another location (ie. "/WEB-INF/new-felix/new-load") 2.2. Manually copying the JAR file should actually work against the custom location. Tests done showed that Upload Plugin functionality is only working against the default location
-
Some questions arose when doing further analysis: 3.1. Should customized properties be assumed always relative to Tomcat's "webapps/ROOT" directory? I mean, is there a requirement to support "absolute paths" as possible values for the properties? If that's the case, we might need to differentiate between absolute vs. relative values by using a starting slash (If so, a path like "/WEB-INF/..." may be interpreted as absolute to the file-system and a path like "WEB-INF/..." may be interpreted as relative to the Tomcat's "webapps/ROOT" directory. 3.2. Should customized directories be assumed to pre-exist at the moment Upload functionality is exercised? I mean, currently our default Felix directories are pre-created inside dotCMS bundle (they pre-exist). In opposition to it, wondering if -now that locations can be customized- system should automatically create them or at least fallback to default location if they don't exist?
For now, marking ticket as "Needs Work" (mainly because item 1 but leaving the another items subject to consideration, hence also marking ticket as "Needs Discussion").
Thanks, Anibal
@agomez-dotcms and @danlaguna:
Here is what we need. We need to be able to run all functions in dotCMS without being able to write anything under /tomcat/* anything
-
Seems like bug and should be fixed
-
Felix is looking for the felix variables to be set as system properties. This means that when we init osgi, if we read any felix properties from the dotmarketing-config.properties we probably need to set them as system properties, e.g.
felix.fileinstall.dirfor felix to respect them under the covers. Our properties should have exactly the same names as the felix config properties. See: http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html -
We need to be able to configure felix to run from a completely different path (or volume) than under
/WEB-INF/. You should get a USB thumb drive or mount a loopback block device and configure felix to test loading from there, e.g./Volume/sandisk1/felix- with no symlinks All functions should work, including uploading from the UI AND manually loading on the file system. Also, I would rather set the default felix directory to Config.CONTEXT.getRealPath("/WEB-INF/felix") than do any funk with the relative/absolute pathing, e.g.:
final String FELIX_BASE_FOLDER = Config.getStringProperty("FELIX_BASE_FOLDER", Config.CONTEXT.getRealPath("/WEB-INF/felix"));
3.2. We should create the needed directories if they do not exist on upload.
The final touches on the felix base dir impl have been completed. Now the customer or developer can define and overwrite the felix base path by defining a new property (felix.felix.base.dir). I have created a Google Document for support: https://docs.google.com/document/d/1cD_m7PQiobMrrbvG-qfZz424AE0c56Qu9Ayo2sDf6VU/edit
have we made sure that the velocity portlet works
On Mon, Apr 24, 2017 at 5:27 PM Daniel Laguna [email protected] wrote:
The final touches on the felix base dir impl have been completed. Now the customer or developer can define and overwrite the felix base path by defining a new property (felix.felix.base.dir). I have created a Google Document for support:
https://docs.google.com/document/d/1cD_m7PQiobMrrbvG-qfZz424AE0c56Qu9Ayo2sDf6VU/edit
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dotCMS/core/issues/10370#issuecomment-296827203, or mute the thread https://github.com/notifications/unsubscribe-auth/ABfteGtUKIsitRchKUCksUBMdeC6Akh5ks5rzROigaJpZM4LUc8e .
@dotcmsCodeReview you are talking about this issue right? https://github.com/dotCMS/core/issues/11303
I haven't merged that one yet (https://github.com/dotCMS/core/issues/11303), and yes that's going to be the QA. Velocity Portlet it is
Passed QA
- Verified that felix default folder location is created when felix property is not defined in dotmarketing-config.properties. Uploaded successfully osgi plugin and bundle
- Verified that felix custom folder is created when felix property (felix.base.dir and felix.felix.base.dir) is defined in dotmarketing-config.properties. Uploaded successfully osgi plugin and bundle
- Verified that felix custom folder is created when defining an environment variable and felix property (felix.base.dir and felix.felix.base.dir) is defined in dotmarketing-config.properties (e.g.: felix.base.dir={env:customFelixBaseDir}). Uploaded successfully osgi plugin and bundle
- Uploaded a few osgi plugins/bundles and worked fine
Tested in dotcms 4.1.0 distribution Mac OS 10.10 / MySQL 5.6.35 / Firefox v45.0.1 / Tomcat 8 / Java 8
Documented: https://auth.dotcms.com/docs/latest/distributed-osgi-bundles
PR for fixing not forcing "load" in load's path: https://github.com/dotCMS/core/pull/11758 PR for 4.1: https://github.com/dotCMS/core/pull/11761
updated the documentation: https://authoring.dotcms.com/docs/latest/distributed-osgi-bundles
Looks great, guys @danlaguna @DeanGonzalez . We still need to update this doc https://authoring.dotcms.com/docs/latest/osgi-plugins#FileLocations to be consistent