Legacy Knowledge Base
Published 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

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

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