Legacy Knowledge Base
公開されました Sep. 10, 2025

ConfigurationProviderUtil returns empty values for a custom 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.

Issue

  • A custom module reads a system configuration with ConfigurationProviderUtil.getSystemConfiguration, but the values it returns are empty. For example, this code returns an empty elasticServerHosts array, even though hosts are configured:

    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();
    
  • Every attribute of the configuration comes back empty: strings are empty, arrays have no elements, and numbers and booleans are 0 and false. Default values set with @Meta.AD(deflt = ...) are not applied either. No error is logged at the default log level.

Environment

  • Liferay DXP 7.4+

Resolution

WARNING
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.

The configuration interface has a required attribute. An @Meta.AD attribute is required unless it sets required = false.

  • On Liferay DXP 2025.Q1 and later, the configuration is returned once every required attribute has a saved value. Set required = false on each attribute that does not need an administrator's value. Otherwise, save a value for every required attribute in System Settings or in a .config file.
  • On earlier releases, a configuration with any required attribute returns no values, even after values are saved. Set required = false on each attribute that does not need to be required. If an attribute must stay required, read the configuration with ConfigurableUtil in a component bound to the configuration PID:

    @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

For how to declare and read a configuration, see:

Did this article resolve your issue ?

Legacy Knowledge Base