OSGI Configuration Values are not getting updated | Community
Skip to main content
May 11, 2022
Solved

OSGI Configuration Values are not getting updated

  • May 11, 2022
  • 4 replies
  • 5567 views

Hi, 

We are facing an issue where OSGI configuration values are not getting updated when we check in the /system/console/ConfigMgr

For Ex:
If we make changes in the config file and deploy the same it reflects correctly in crx/de But not in /system/console/ConfigMgr.
We still see old value and have to manually make the changes. 
We have taken care of run modes as well so that they should reflect the respective values. 



 

Thanks,

Mrudul

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by DEBAL_DAS

@debal_das 

Sorry it didnt work and we have same issue.  
We deleted the config and made some small update in the config file in crx. and observed config got recreated but values are empty and still  PID is not linked to config class.


Here is my sample OSGi configuration associated with Scheduler -

package com.aem.demo.core.configurations;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "Resource Expiration scheduler configuration", description = "Resource Expiration scheduler configuration")
public @interface ExpirationSchedulerConfiguration {

	/**
	 * This method will return the name of the Scheduler
	 * 
	 * @return {@link String}
	 */
	@AttributeDefinition(name = "Scheduler name", description = "Name of the scheduler", type = AttributeType.STRING)
	public String schdulerName() default "Expiration scheduler configuration";

	/**
	 * This method will set flag to enable the scheduler
	 * 
	 * @return {@link Boolean}
	 */

	@AttributeDefinition(name = "Enabled", description = "True, if scheduler service is enabled", type = AttributeType.BOOLEAN)
	public boolean enabled() default false;

	/**
	 * This method returns the Cron expression which will decide how the scheduler
	 * will run
	 * 
	 * @return {@link String}
	 */

	@AttributeDefinition(name = "Cron Expression", description = "Cron expression used by the scheduler", type = AttributeType.STRING)
	public String cronExpression() default "0 * * * * ?";

	/**
	 * This method returns the Asset Path
	 * 
	 * 
	 * @return {@link String}
	 */

	@AttributeDefinition(name = "Asset Path", description = "Asset Path", type = AttributeType.STRING)
	public String assetPath() default "/content/dam";

	@AttributeDefinition(name = "Page Taxonomy", description = "Page Taxonomy", type = AttributeType.STRING)
	public String contentPath() default "/content/we-retail";

}

This is Scheduler where I am reading the above OSGi configuration -

package com.aem.demo.core.configurations;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "Resource Expiration scheduler configuration", description = "Resource Expiration scheduler configuration")
public @interface ExpirationSchedulerConfiguration {

	/**
	 * This method will return the name of the Scheduler
	 * 
	 * @return {@link String}
	 */
	@AttributeDefinition(name = "Scheduler name", description = "Name of the scheduler", type = AttributeType.STRING)
	public String schdulerName() default "Expiration scheduler configuration";

	/**
	 * This method will set flag to enable the scheduler
	 * 
	 * @return {@link Boolean}
	 */

	@AttributeDefinition(name = "Enabled", description = "True, if scheduler service is enabled", type = AttributeType.BOOLEAN)
	public boolean enabled() default false;

	/**
	 * This method returns the Cron expression which will decide how the scheduler
	 * will run
	 * 
	 * @return {@link String}
	 */

	@AttributeDefinition(name = "Cron Expression", description = "Cron expression used by the scheduler", type = AttributeType.STRING)
	public String cronExpression() default "0 * * * * ?";

	/**
	 * This method returns the Asset Path
	 * 
	 * 
	 * @return {@link String}
	 */

	@AttributeDefinition(name = "Asset Path", description = "Asset Path", type = AttributeType.STRING)
	public String assetPath() default "/content/dam";

	@AttributeDefinition(name = "Page Taxonomy", description = "Page Taxonomy", type = AttributeType.STRING)
	public String contentPath() default "/content/we-retail";

}

As I am reading OSGi configuration in above scheduler so, PID is pointing to Scheduler Class itself as shown below -

 

I have deployed everything on local AEM author instance and every time I am modifying contentpath in CRXDE here /apps/demo/osgiconfig/config.author/com.aem.demo.core.schedulers.ResourceExpirationScheduler.config and change is getting reflected in config manager /system/console/configMgr.

 

My sample OSGi configurations is getting stored in file system under following path

C:\Users\debal\AEM-instances\demo-author\crx-quickstart\launchpad\config\com\aem\demo\core\schedulers here -

 

If we take close look this path is nothing but 

<AEM-instance-installed-directory>/crx-quickstart/launchpad/config/PID

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 replies

Ravi_Pampana
Community Advisor
Community Advisor
May 11, 2022

Hi,

 

Are you overwriting the out of the box configuration or it is custom config? Try adding some unique value at the end of the config file, if it is out of the box config you are updating

 

Ex: org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl-<uniqueid>.

MrudulMoAuthor
May 12, 2022

@ravi_pampana No We are not overwriting OOTB config. It is a custom config

DEBAL_DAS
May 12, 2022

We had similar issue in our project. If you are having OSGi configuration structure like the below one -

 

Then please check config file[PID] under relevant config folder like config.author or config.publish or config.stage which is aligned with the run mode of that AEM instance and make necessary changes in that config file[PID].

 

MrudulMoAuthor
May 12, 2022

Hi @debal_das 
Yes, config files are having a correct naming convention and are placed in respective run modes. 
One thing we noticed here is PID is not bound to the class name but rather shows Configuration Name. 

 




DEBAL_DAS
May 13, 2022

Let's assume you are on prod author instance and this OSGi configuration will be having prod environment specific value.

 

Now tell me location of config file in CRXDE (full path), where you have updated the value.

May 12, 2022

Are you creating your configurations as "sling:OsgiConfig" node . I am not seeing anything in crxde like below 

<?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"

 

Check this configuration for reference /apps/weretail/config/org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-we-retail

MrudulMoAuthor
May 12, 2022

Yes @an1-3  We have taken care of this. 

Vijayalakshmi_S
Level 10
May 17, 2022

@mrudulmo 

If you are using OSGi annotation,

Cross check the @Designate annotation if the OCD is correctly associated to an OSGi component. 

If it is a factory config,  @Designate should have additional property named factory set to true.