Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Issue- AEM 6.4 Configurations not picking values from runmode config

Avatar

Level 10

All,

I am in the process of migrating code to 6.4 and i noticed that i see the configurations in config tab of felix console,it is also registered as a component,  and i can edit and set values as well which persist, but persistence occurs at the system folder and not at config.local.author or config.local. Neither does it retrieve the values from the config.local.author folder for the configuration.

I did set up the run mode for the instance

Sample class

@Component(immediate = true,name="Service",service= Service.class, configurationPid="com.test.core.services.Service",property={

        Constants.SERVICE_DESCRIPTION + "=Service",

        Constants.SERVICE_VENDOR + "=Test"

}) // added configurationPid="com.test.core.services.Service" so that it reflects the configuration in the components tab for the component

//@Designate(ocd = Service.Config.class)  // Commented this out to avoid duplicate configurations from appearing in felix console

public class Service {

private static String appID;

public String getAppID() {

        return appID;

    }

@ObjectClassDefinition(name = "Service config", pid="com.test.core.services.Service",description = "Description") // added PID for it to reflect in the felix console configuration

    public @interface Config {

    @AttributeDefinition(name = "App ID",  description = "Description")

    String getAppID();

    @Activate

  protected void activate(Config config) {

    if (config != null) {

            String appID = PropertiesUtil.toString(config.getAppID(), "");

          }

     }

}

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I don't know if I understood your above query correct or not.

You want to save appid config value in repository based config?

you can use Apache Sling Logging Logger config, where values store and name has period.

Screen Shot 2018-06-04 at 10.26.30 PM.png

If you want to create names for Osgi config properties like above org.apache.sling ... with dot  , you can use "_", It will be converted into dot.

The AttributeDefinition method naming convention will immediately seem out of place. It's very Pythonic looking with its use of underscores. You don't need to write your method names that way, but the reason for doing so is that the underscores are converted to dots for display in the Felix console and your OSGi configs. For example, you're probably familiar with seeing properties defined as something like resource.resolver.searchpath. To achieve this in your configuration class, your method would be named resource_resolver_searchpath.

More info below

Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S...

Thanks

Arun



Arun Patidar

View solution in original post

9 Replies

Avatar

Community Advisor

Hi,

You may have to create the config under your custom location /apps/my-project/config.local prior to making any changes in configMgr. Only then the changes made in configMgr will be reflected in that custom directory because the OSGI will bind the config properly to your /apps/my-project/config.local.

If you make changes in configMgr prior to creating this your custom /apps/my-project/config.local then the config will be bound to /apps/system/config and you're doomed. you need to delete in crx/de the related files from /apps/system/config

You might also need to delete the related config in crx-quickstart:

\crx-quickstart\launchpad\config\..some further path

and restart the instance.

Thanks

Arun



Arun Patidar

Avatar

Level 10

Hey Arun,

Thanks for the response.

So i refactored the code for 6.4 removing scr annotations, and the code package contained configurations under the specific run mode , so when i build the apps to aem, should the values not reflect in the configuration manager for the configuration? I am sorry i am new to 6.4 unsure if i am missing something here.

I did test it by setting values and they get stored under /system, so i knocked them off and ran a build, still no luck, the config values are empty although i see the values under config.local.author/com....test.config

I tried knocking off the configs under \crx-quickstart\launchpad\config\..some further path but in vain

Could i be setting the run mode incorrectly? i now again don't see the local run mode. Would you mind letting me know the way i could start with a run mode in 6.4

Avatar

Community Advisor

I tried above steps again and I can see my config values are reflecting web console config manager when I changed in Repository.

The run mode basically for repository based configuration but seems your want to change web console based config location.

To achieve that, if you change repository config values from web console your web console changes will be saved in config.local and your repository config will be invalidated.

Screen Shot 2018-06-04 at 9.02.42 PM.png

Thanks

Arun



Arun Patidar

Avatar

Level 10

Thanks i see the run mode set in sling settings but unable to get the values in the config, is the code that i have attached look ok?

Avatar

Level 10

ok so now i change values in felix console and it reflects on the config.local config but i dont see the values from the config under config.local in felix console, is there an issue with the code?

Avatar

Community Advisor

Hi,

If you change the value of config in Felix console, it would be save in flat file in config.local e.g. /apps/myproj/config.author/com.aem64.core.DeveloperInfoImpl.config/jcr:content

You can click on view in jcr:date property and check the values.

Screen Shot 2018-06-04 at 9.47.42 PM.png

Thanks

Arun



Arun Patidar

Avatar

Level 10

so i figured out the issue, i see that the name being stored by the prev developers was com..test.core.abc.appid. How do i set this to a configuration in 6.4? I don't believe we could have a string with period as the name ?

Avatar

Correct answer by
Community Advisor

I don't know if I understood your above query correct or not.

You want to save appid config value in repository based config?

you can use Apache Sling Logging Logger config, where values store and name has period.

Screen Shot 2018-06-04 at 10.26.30 PM.png

If you want to create names for Osgi config properties like above org.apache.sling ... with dot  , you can use "_", It will be converted into dot.

The AttributeDefinition method naming convention will immediately seem out of place. It's very Pythonic looking with its use of underscores. You don't need to write your method names that way, but the reason for doing so is that the underscores are converted to dots for display in the Felix console and your OSGi configs. For example, you're probably familiar with seeing properties defined as something like resource.resolver.searchpath. To achieve this in your configuration class, your method would be named resource_resolver_searchpath.

More info below

Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache S...

Thanks

Arun



Arun Patidar

Avatar

Level 10

Thanks Arun, followed above steps and have it working now., Appreciate it