Why sling:OsgiConfig node not working in /etc/folder in AEM?
Asked Answered
B

2

7

I have a component with properties as follows.

@Component(immediate = true, metatype = true, label = "Conf Details")
@Service(value = { LocationConfigurationUtil.class })
@Properties({
        @Property(label = "location blueprint", name = "locationPath", value = "", description = "..."),
        @Property(label = "location page template", name = "locationTemplate", value = "", description = "..."),
        @Property(label = "basepath live copies", name = "liveCopyRoot", value = "/content/WebRoot", description = "...") })
public class LocationConfigurationUtil {
@Activate
    protected void activate(Map<String, Object> mapCreated) {
          // some code
    }
}

To make it editable properties in a jcr node, I used a non-standard method. I created sling:OsgiConfig in path /apps/system/config having properties declared in java code, which is working fine.

screen shot

But if I just have the same sling:OsgiConfig inside /etc/myapp/myconfig, it does not work.

Bursar answered 1/3, 2016 at 6:41 Comment(0)
C
10

With default settings, JCR Installer Provider does not look for installable bundles and nodes (sling:OsgiConfig) in folders other than /libs and /apps. so any config in /etc will not be loaded.

If you want to change this behavior, make a search path entry in "Apache Sling JCR Installer" config in osgi configuration console. But be aware it is not recommended, you should not be putting any sling:osgiconfig node in /etc in the first place.

Crawly answered 1/3, 2016 at 8:10 Comment(2)
It started working in /etc/system/config/, after adding /etc:300. But inside folder /etc/myapp/myconfig still not working.Bursar
Rename the folder myconfig to config.Crawly
P
5

Note that placing configuration nodes under /etc is a really bad idea.

From a security point of view, /libs and /apps are locked down, but with /etc/ you open yourself up to at least two major security holes:

  • OSGi configurations can be read by anonymous users
  • Code can be deployed by unprivileged users

Please reconsider adding the /etc path to the JCR Installers search path entries and instead deploy your configurations to /apps.

Placement answered 14/3, 2016 at 13:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.