Issue
After editing a config or configuration file in the osgi/configs folder, there are unexpected errors during the startup process, that can prevent Liferay from starting correctly
The errors detected in 7.2 Fixpack 11 and 12 are:
- After editing the Elasticsearch configuration
2021-03-29 06:49:06.923 ERROR [Start Level: Equinox Container: 8ad2e3a5-ae58-4508-b530-a0a1173287a8][CompanyIdIndexNameBuilder:93] bundle com.liferay.portal.search.elasticsearch6.impl:3.0.83 (637)[com.liferay.portal.search.elasticsearch6.internal.index.CompanyIdIndexNameBuilder(1688)] : The activate method has thrown an exception java.lang.RuntimeException: Unable to create snapshot class for interface com.liferay.portal.search.elasticsearch6.configuration.ElasticsearchConfiguration at com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil._createConfigurableSnapshot(ConfigurableUtil.java:89) at com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil.createConfigurable(ConfigurableUtil.java:51) [...]
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at com.liferay.portal.configuration.metatype.bnd.util.ConfigurableUtil._createConfigurableSnapshot(ConfigurableUtil.java:86) ... 47 more Caused by: java.lang.IllegalArgumentException: No enum constant com.liferay.portal.search.elasticsearch6.configuration.OperationMode."REMOTE" at java.base/java.lang.Enum.valueOf(Enum.java:240) at aQute.bnd.annotation.metatype.Configurable$ConfigurableHandler.convert(Configurable.java:179) at aQute.bnd.annotation.metatype.Configurable$ConfigurableHandler.invoke(Configurable.java:103) at com.sun.proxy.$Proxy263.operationMode(Unknown Source) at com.liferay.portal.search.elasticsearch6.configuration.ElasticsearchConfigurationSnapshot.(Unknown Source) ... 52 more
- After editing the REST services configuration
16-Jul-2021 09:35:29.732 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [com.liferay.portal.spring.context.PortalContextLoaderListener]
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:308)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4690)
[...]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:474)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.liferay.portal.bootstrap.ModuleFrameworkImpl._installConfigs(ModuleFrameworkImpl.java:1295)
at com.liferay.portal.bootstrap.ModuleFrameworkImpl._setUpInitialBundles(ModuleFrameworkImpl.java:1815)
at com.liferay.portal.bootstrap.ModuleFrameworkImpl.startFramework(ModuleFrameworkImpl.java:404)
at com.liferay.portal.module.framework.ModuleFrameworkUtilAdapter.startFramework(ModuleFrameworkUtilAdapter.java:100)
at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:303)
... 41 more
Caused by: java.lang.IllegalArgumentException: Value must not be null
at org.apache.felix.cm.impl.CaseInsensitiveDictionary.checkValue(CaseInsensitiveDictionary.java:286)
at org.apache.felix.cm.impl.CaseInsensitiveDictionary.(CaseInsensitiveDictionary.java:83)
at org.apache.felix.cm.impl.ConfigurationImpl.update(ConfigurationImpl.java:452)
at org.apache.felix.cm.impl.ConfigurationAdapter.update(ConfigurationAdapter.java:145)
at com.liferay.portal.file.install.internal.configuration.ConfigurationFileInstaller.transformURL(ConfigurationFileInstaller.java:141)
When we install the fixpack 13 in Liferay DXP 7.2 or the fixpack 2 in Liferay DXP 7.3, the following warning traces are written to the log file:
Detected .config format in .cfg file in line:
Unable to parse config line:
Environment
- Liferay DXP 7.2
Resolution
- These errors are produced because you have a
.configfile that contains lines in the.cfgfile format or vice-versa. - The
osgi/configsfolder supports two types of files:- Typed .config files format - Configuration files (external link)
- Type-less .cfg files format - Property files (external link)
- Before DXP 7.2 fixpack 11, it was possible to mix the
.configand.cfgformats in the same file but as of fixpack 11, Liferay no longer allows it so having a file with the wrong format will cause an error in the log files. - To solve your issue, you have to review all your configuration files included in the
osgi/configsfolder and double-check they contain the correct format. - The major difference between both formats is:
-
.cfgfile lines are always unquoted, for example:-
-
key=value
-
-
-
.configfile lines are always quoted, and they can have a type, for example:
-
-
key_string="value"
-
key_boolean=B"false"
-
-
-
- The official Liferay recommendation is to stop using the old
.cfgformat and change all the files to the.configone because it allows using typed values and the.cfgwill be deprecated in a future Liferay version - For more information about the Liferay OSGi configuration files, see Creating Configuration Files
Additional Information
- Liferay documentation: Creating Configuration Files
- Apache documentation:
- Typed .config files format - Configuration files (external link)
- Type-less .cfg files format - Property files (external link)