Hello Bertrand,

Thank you for your reply, sure I can try to clarify.

I have two bundles, bundle-core and bundle-ui.

BUNDLE-CORE:
declares an ImageComponentService, on which I can configure the URL to the
main directories containing images:

  @Property(label="Images root URL", description="URL to the web directory
containing image files")
  public static final String IMAGE_ROOT_URL = "image.root.url";

I don't want to intialize it with a sling:OsgiConfig nodes because its
value depends on the environment and it wouldn't make sense to provide
default values.

BUNDLE-UI
Contains JSPs and Angular stuff. With Sling-initial-content, it imports a
config.json file in /libs/myApp/bundle-ui/install to configure the JSP
engine factory:
  "org.apache.sling.scripting.jsp.JspScriptEngineFactory":{
    "jcr:primaryType":"sling:OsgiConfig",
    "jasper.trimSpaces":true
}



1. I deploy bundle-core with the Maven Sling plugin, ImageComponentService
is registered and I can modify the configuration through the Felix web
console.I see in the logs that it's registered:

[FelixFrameworkWiring] INFO  com.roche.opal.core - Service
[com.roche.opal.core.services.models.components.ImageCommentComponentService,853]
ServiceEvent REGISTERED


2. Through the Felix web console, I set a value for the "image.root.url"
property, and I see that in the logs:

[CM Event Dispatcher (Fire ConfigurationEvent:
pid=com.roche.opal.core.services.models.components.ImageComponentServiceImpl)]
INFO  com.roche.opal.core - Service
[com.roche.opal.core.services.models.components.ImageComponentServiceImpl,616]
ServiceEvent UNREGISTERING
[CM Event Dispatcher (Fire ConfigurationEvent:
pid=com.roche.opal.core.services.models.components.ImageComponentServiceImpl)]
INFO  com.roche.opal.core - Service
[com.roche.opal.core.services.models.components.ImageComponentServiceImpl,660]
ServiceEvent REGISTERED

My value is displayed in the Felix web console, so far everything works as
expected.


3. I deploy bundle-ui with the Maven Sling plugin. During deployment, I see
it removes the configuration previously set and deletes the configuration
folder:

[JcrInstaller.1] INFO  o.a.s.i.p.jcr.impl.JcrInstaller - Removing resource
from OSGi installer:
[/apps/sling/install/c.r.o.c.services.models.components.ImageComponentServiceImpl.config,]
[JcrInstaller.1] INFO  o.a.s.i.p.jcr.impl.JcrInstaller - Deleting
WatchedFolder:/apps/sling/install, path does not exist anymore


===> Consequently, I have to configure bundle-core each time I deploy
bundle-ui.


I don't have this problem for properties that are initialized from
config.json with sling:OsgiConfig nodes that I put in /libs/install (with
Sling-initial-content in my POM), they are not removed but I see two
problems with that workaround:

- it duplicates configuration settings, I thought just using the @Property
annotation was enough, and one day I will forget to put the property in the
JSON file.
- it doesn't work for configuration factories. For instance, I have another
bundle-auth where I can configure many LDAP servers. Even if they're
initialized, if the user adds another configuration through the Felix web
console, it will be removed when bundle-ui is deployed.

I have seen SLING-4925 / SLING-4929 and tried to update Jackrabbit server
(I'm using Sling 7) but it didn't help.
I have also tried to update the installer with these versions:
org.apache.sling,org.apache.sling.installer.factory.configuration,1.1.2
org.apache.sling,org.apache.sling.installer.core,3.6.8

But no luck either.

So I'm wondering if just declaring a Property in your service, and setting
the value through the Felix web console is supposed to work and not being
removed when deploying another bundle that imports its own configuration,
or if I'm doing something wrong.

I've read the documentation about the JCR Installer here:
https://sling.apache.org/documentation/bundles/jcr-installer-provider.html
But it doesn't explain how configuration sources could collide.

I hope it's clear enough, let me know if you need further information.

Thank you for your help!

Best regards,
Guillaume

On Wed, Jul 6, 2016 at 10:33 AM, Bertrand Delacretaz <[email protected]
> wrote:

> Hi Guillaume,
>
> On Wed, Jul 6, 2016 at 9:01 AM, Guillaume Lucazeau <[email protected]>
> wrote:
> > ...I've found out that if a configuration is initialized through a
> > sling:OsgiConfig node in a config.json file in /libs/myApp/install, the
> > configuration (even modified through the web console) is not removed by
> the
> > JCR Installer when I deploy another bundle...
>
> I'm not sure if I understand exactly what you are doing, can you
> clarify in the form of a simple scenario that we can use to reproduce
> your issue? A test case is even better if you have one.
>
> -Bertrand
>

Reply via email to