Highlighted

3 Gotchas in Migrating from Felix SCR to OSGi R6 Annotations

dan_klco

21-05-2018

Avoid these three gotchas to make your migration from ApacheFelix SCR Annotations -> OSGi R6 DS Annotations quick and painless!

3 Gotchas in Migrating from Felix SCR to OSGi R6 Annotations – Perficient+Adobe

Replies

Highlighted

sanjeevk2270226

23-05-2018

Thanks @smacdonald2018, @dan.klco.

I am facing weird issue when migrating to OSGI DS. I am referring the following osgi service and configuration

Service: https://github.com/nateyolles/aem-osgi-annotation-demo/blob/master/core/src/main/java/com/nateyolles...

Config: https://github.com/nateyolles/aem-osgi-annotation-demo/blob/master/core/src/main/java/com/nateyolles...

Deploy for first time works. However when I override this config by adding the following file to /apps/test/config.author/com.test.core.services.SampleOsgiServiceImpl-code.xml. After deploying I see two configuration files in /system/console/configMgr:

1. one with default config from code

2. second with updated property I added in following config, rest of the properties also show up and inherited from default code configuration.

file:/apps/test/config.author/com.test.core.services.SampleOsgiServiceImpl-code.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
   jcr:primaryType="sling:OsgiConfig"
   servicename.propertyname.string = "TESTTEST1"
/>

I hope I am not the first one to try this scenario!! please let me know if I am missing anything?

I've also tried the service, configuration from https://blog.osoco.de/2015/08/osgi-components-simply-simple-part-ii/ , then override with a config file in /apps. Same issue - I see two configs in configMgr.

Highlighted

dan_klco

24-05-2018

sanjeevk2270226​ Why are you adding -config to your configuration PID? The file name should exactly match the PID of the service being registered. Adding -config may cause OSGi to treat the service as a factory and register multiple configuration. Try renaming /apps/test/config.author/com.test.core.services.SampleOsgiServiceImpl-code.xml to /apps/test/config.author/com.test.core.services.SampleOsgiServiceImpl.xml