legacy-knowledge-base
公開されました Sep. 10, 2025

Need to get values from System Configuration

written-by

Apsara Raheja

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

NOTE: The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.

Issue

  • How to fetch the elasticServerHosts values using ConfigurationProviderUtil from the System configuration interface with the below code (custom):
    import com.liferay.portal.configuration.module.configuration.ConfigurationProviderUtil;

    DidYouMeanConfiguration DidYouMeanConfiguration = null;

    try {

    DidYouMeanConfiguration = ConfigurationProviderUtil

    .getSystemConfiguration(DidYouMeanConfiguration.class);

    } catch (ConfigurationException e) {

    log.error(e);

    }

    String[] elasticServerHosts = DidYouMeanConfiguration.getElasticServerHosts();
  • It returns the size of the string array 0 instead of the actual size.

Environment

  • DXP 2023 Q4.4

Resolution

  • Fetch the configuration by ConfigurableUtil like below:
    @Component(
    configurationPid = "com.custom.search.suggestion.conf.DidYouMeanConfiguration",
    service = TestComponent.class
    )
    public class TestComponent {

    @Activate
    @Modified
    protected void activate(Map<String, Object> properties) {
    _DidYouMeanConfiguration = ConfigurableUtil.createConfigurable(
    DidYouMeanConfiguration.class, properties);
    }

    private volatile DidYouMeanConfiguration
    _DidYouMeanConfiguration;

    }

Additional Information

  • This requirement involves the implementation and development of code which mainly comes under the scope of the global services. 
did-this-article-resolve-your-issue

legacy-knowledge-base