Bitbucket could not be started due to java.nio.file.FileAlreadyExistsException

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 is not able to start and has this error "SpringMVC dispatcher [springMvc] could not be started" in the logs.

Environment

Bitbucket 7.21.4

Diagnosis

During Bitbucket startup, after it acquires lock on Bitbucket home directory, it fails to start while creating temporary files and the error below is seen in the Bitbucket logs. 

1 2 3 4 2023-02-04 18:53:36,918 ERROR [spring-startup] c.a.j.s.w.s.JohnsonDispatcherServlet SpringMVC dispatcher [springMvc] could not be started org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gitHookInstaller' defined in com.atlassian.stash.internal.scm.git.GitWiring$LocalWiring: Invocation of init method failed; nested exception is java.nio.file.FileAlreadyExistsException: BITBUCKET_HOME/shared/config/git/hooks/pack-objects.tmp -> /BITBUCKET_HOME/shared/config/git/hooks/tmp-xxx-pack-objects.tmp ... Caused by: java.nio.file.FileAlreadyExistsException: BITBUCKET_HOME/shared/config/git/hooks/pack-objects.tmp -> BITBUCKET_HOME/shared/config/git/hooks/tmp-xxx-pack-objects.tmp

Cause

On startup, Bitbucket acquires a lock on the home directory, creates temporary files (one among them is git hook script temp files) which are usually deleted automatically on graceful shutdown. However, these tmp files were not deleted during shutdown. During startup, Bitbucket complained that a file already exists at the specific location and failed to start.

Solution

Delete the BITBUCKET_HOME/shared/config/git/hooks/pack-objects.tmp file and start Bitbucket.

Updated on March 11, 2025

Still need help?

The Atlassian Community is here for you.