Exception in thread "main" java.lang.NoClassDefFoundError

Hi Team,

I am a beginner in Elasticsearch. We have a wazuh cluster running which use Elasticsearch for storing alerts. Since few days, the Elasticsearch is not starting at al. Whenever we try to use "systemctl start elasticseach.service" we are hitting below exception.

Jun 15 14:38:03 wazuh-2 systemd[1]: Starting Elasticsearch...
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at org.elasticsearch.cli.CommandLoggingConfigurator.configureLoggingWithoutConfig(CommandLoggingConfigurator.java:40)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at org.elasticsearch.cli.Command.main(Command.java:87)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at org.elasticsearch.common.settings.KeyStoreCli.main(KeyStoreCli.java:43)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]: Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Jun 15 14:38:04 wazuh-2 systemd-entrypoint[967205]:         ... 3 more
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]:         at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:90)
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]: Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]:         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]:         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]:         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Jun 15 14:38:07 wazuh-2 systemd-entrypoint[967128]:         ... 1 more
Jun 15 14:38:08 wazuh-2 systemd[1]: elasticsearch.service: Main process exited, code=exited, status=1/FAILURE
Jun 15 14:38:08 wazuh-2 systemd[1]: elasticsearch.service: Failed with result 'exit-code'.
Jun 15 14:38:08 wazuh-2 systemd[1]: Failed to start Elasticsearch.

We have tried to add the Classpath using export CLASSPATH=$CLASSPATH:/usr/share/elasticsearch/ However this does not solve the problem.

Can someone please suggest how can I resolve this error.

What do the actual Elasticsearch logs show?

Hi,.

Thank you for your response. I managed to troubleshoot the issue. The base OS on which elasticsearch was installed was updated to Ubuntu 22. During Upgradation, many packages were lost due to which log4j was not able to start.

We Reinstalled Elasticsearch with all it's dependencies after which it started working.