"Exception in thread "main" java.util.zip.ZipException: zip file is empty" while starting Bitbucket Datacenter container

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

Bitbucket container fails to start with the message "Exception in thread "main" java.util.zip.ZipException: zip file is empty"

Environment

Tested on Bitbucket 8.14 and 8.18

Docker

Diagnosis

While running the docker-compose up command, you'll see the below messages on the terminal:

Click here to see the full output on the terminal

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 bitbucket | WARNING:root:###################################################################### bitbucket | WARNING:root:Starting Bitbucket with embedded search service. Note that this is bitbucket | not a recommended configuration and is known to have issues with bitbucket | clean shutdown. Ideally OpenSearch (previously Elasticsearch) should bitbucket | be started in a separate container/pod. bitbucket | WARNING:root:###################################################################### bitbucket | INFO:root:User is currently root. Will downgrade run user to bitbucket bitbucket | INFO:root:Running Bitbucket with command '/opt/atlassian/bitbucket/bin/start-bitbucket.sh', arguments ['/opt/atlassian/bitbucket/bin/start-bitbucket.sh', '-fg'] bitbucket | Starting Atlassian Bitbucket as the current user bitbucket | bitbucket | Starting the bundled search server bitbucket | Hint: Run start-bitbucket.sh --no-search to skip starting the bundled search server bitbucket | Bundled search server started successfully bitbucket | bitbucket | Bitbucket is being run with a umask that contains potentially unsafe settings. bitbucket | The following issues were found with the mask "u=rwx,g=rx,o=rx" (0022): bitbucket | - Access is allowed to 'others'. It is recommended that 'others' be denied bitbucket | all access for security reasons. bitbucket | The recommended umask for Bitbucket is "u=,g=w,o=rwx" (0027) and can be bitbucket | configured in _start-webapp.sh bitbucket | bitbucket | Starting Bitbucket webapp at http://localhost:7990 bitbucket | Exception in thread "main" java.util.zip.ZipException: zip file is empty bitbucket | at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1762) bitbucket | at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1546) bitbucket | at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1641) bitbucket | at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1479) bitbucket | at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1441) bitbucket | at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:718) bitbucket | at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:252) bitbucket | at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:181) bitbucket | at java.base/java.util.jar.JarFile.<init>(JarFile.java:346) bitbucket | at java.base/java.util.jar.JarFile.<init>(JarFile.java:317) bitbucket | at java.base/java.util.jar.JarFile.<init>(JarFile.java:283) bitbucket | at org.springframework.boot.loader.jar.AbstractJarFile.<init>(AbstractJarFile.java:39) bitbucket | at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:130) bitbucket | at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:125) bitbucket | at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:111) bitbucket | at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:102) bitbucket | at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:73) bitbucket | at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:69) bitbucket | at com.atlassian.bitbucket.internal.launcher.BitbucketServerLauncher.postProcessClassPathArchives(BitbucketServerLauncher.java:146) bitbucket | at org.springframework.boot.loader.ExecutableArchiveLauncher.applyClassPathArchivePostProcessing(ExecutableArchiveLauncher.java:142) bitbucket | at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchivesIterator(ExecutableArchiveLauncher.java:125) bitbucket | at com.atlassian.bitbucket.internal.launcher.BitbucketServerLauncher.start(BitbucketServerLauncher.java:156) bitbucket | at com.atlassian.bitbucket.internal.launcher.BitbucketServerLauncher.main(BitbucketServerLauncher.java:99) bitbucket | WARNING: A terminally deprecated method in java.lang.System has been called bitbucket | WARNING: System::setSecurityManager has been called by org.opensearch.bootstrap.OpenSearch (file:/opt/atlassian/bitbucket/opensearch/lib/opensearch-1.3.14.jar) bitbucket | WARNING: Please consider reporting this to the maintainers of org.opensearch.bootstrap.OpenSearch bitbucket | WARNING: System::setSecurityManager will be removed in a future release bitbucket | bitbucket | No process was found for PID 209, or the current user cannot signal it

Cause

While attempting to migrate from MySQL to say Postgres, you remove the volume mapping of the MySQL driver, by removing something similar to the below from the docker-compose.yaml file:

1 2 - /local/app/bitbucket/mysql-connector-j-8.0.32.jar:/var/atlassian/application-data/bitbucket/lib/mysql-connector-j-8.0.32.jar

The above could've been done after successful Database migration, stopping Bitbucket and validating that there is no reference to the MySQL database in both Docker environment variables and the bitbucket.properties configuration file.

This can cause the “Exception in thread "main" java.util.zip.ZipException: zip file is empty” error because Bitbucket still tries to access the MySQL driver after migration, even though there is no configuration reference to MySQL.

Solution

Solution 1

Before running the "docker-compose up"command while using thedocker-compose.ymlfile, go to the/local/data/bitbucket/libpath (which is the volume mapping) and rename the.jarfile.

The above path applies if your docker-compose.yaml file has the below:

1 2 volumes: - /local/data/bitbucket:/var/atlassian/application-data/bitbucket

The contents of this path would look something like this:

1 2 username@ubuntu lib % ls mysql-connector-j-8.0.32.jar_bkup native

Solution 2

There could be a zero-byte file remaining of the MySQL driver in the <Bitbucket-HOME>/lib folder from the time the container was stopped and not mapped with the docker-compose file. Removing the zero-byte file should resolve the issue.

Updated on March 3, 2025

Still need help?

The Atlassian Community is here for you.