Issue
A custom module reads a system configuration with
ConfigurationProviderUtil.getSystemConfiguration, but the values it returns are empty. For example, this code returns an emptyelasticServerHostsarray, 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 = falseon each attribute that does not need an administrator's value. Otherwise, save a value for every required attribute in System Settings or in a.configfile. On earlier releases, a configuration with any required attribute returns no values, even after values are saved. Set
required = falseon each attribute that does not need to be required. If an attribute must stay required, read the configuration withConfigurableUtilin 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:
- Setting and Accessing Configurations
- ConfigurableUtil.java
- The change in 2025.Q1 was made in LPD-33648.