Bundled ElasticSearch fails to start, throws error "EMPTY_BYTE_ARRAY"

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

While starting the Bitbucket application, bundled ElasticSearch fails with the error "Exception in thread "main" java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY"

Environment:

Bitbucket Server 7.6.0, It can occur on the other versions as well. 

Diagnosis

On starting the Bitbucket application using the start-up script, the following stack trace will appear on the terminal. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Exception in thread "main" java.lang.NoSuchFieldError: EMPTY_BYTE_ARRAY     at org.apache.logging.log4j.core.config.ConfigurationSource.<clinit>(ConfigurationSource.java:56)     at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:188)     at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:180)     at org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder.build(DefaultConfigurationBuilder.java:69)     at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:250)     at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)     at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:127)     at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:330)     at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)     at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)     at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)     at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)     at org.elasticsearch.cli.Command.main(Command.java:90)     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)     at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

Cause

The stack trace stated above appears when an incompatible version of the log4j jar is present in the <Bitbucket-Installation-Directory>/elasticsearch/lib/ path and because of that ElasticSearch fails to start.

Solution

Use the same version of the log4j jar file that is shipped with the specific version of Bitbucket Server. It can be extracted from the Same version of Bitbucket server, which can be downloaded here

Updated on March 18, 2025

Still need help?

The Atlassian Community is here for you.