External User Directory synchronisation in Bitbucket server fails with "Unable to create a tracker when osgi is not running" error

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

Synchronisation with external User directory fails with "Unable to create a tracker when osgi is not running" error.

Environment

Bitbucket 8.9 +

Diagnosis

The atlassian-bitbucket.log will have the following stack trace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2023-08-09 09:56:26,960 ERROR [Caesium-1-1] c.a.c.d.DbCachingDirectoryPoller Error occurred while refreshing the cache for directory [ 229377 ]. io.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.IllegalStateException: Unable to create a tracker when osgi is not running at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:156) at io.atlassian.util.concurrent.LazyReference.get(LazyReference.java:116) at io.atlassian.util.concurrent.ResettableLazyReference.get(ResettableLazyReference.java:95) at com.atlassian.stash.internal.crowd.DefaultCrowdDarkFeatureManager.getCrowdDarkFeatureManager(DefaultCrowdDarkFeatureManager.java:58) ..... at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35) at java.base/java.lang.Thread.run(Thread.java:829) ... 20 frames trimmed Caused by: java.lang.IllegalStateException: Unable to create a tracker when osgi is not running at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.getServiceTracker(FelixOsgiContainerManager.java:444) at com.atlassian.stash.internal.crowd.DefaultCrowdDarkFeatureManager$1.create(DefaultCrowdDarkFeatureManager.java:21) at com.atlassian.stash.internal.crowd.DefaultCrowdDarkFeatureManager$1.create(DefaultCrowdDarkFeatureManager.java:18) at io.atlassian.util.concurrent.ResettableLazyReference$InternalReference.create(ResettableLazyReference.java:185) at io.atlassian.util.concurrent.LazyReference$Sync.run(LazyReference.java:332) at io.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:150) ... 34 common frames omitted

Cause

This issue happens when the synchronisation interval is set to every minute. In Bitbucket Datacenter 8.9, we introduced a piece of code that allowed some Crowd specific features to be enabled in Bitbucket, which required service classes exported by plugins. Looking at the exception, it seems that the directory synchronisation is triggered immediately on startup (due to the synchronisation interval being 60 seconds), and this is before the Felix Osgi framework has started.

We have a bug ticket for this issue:

Solution

Workaround

  1. Update the "Synchronisation interval" value for that particular User Directory from the current value of 1 minute to a longer duration, for example, 5 minutes

  2. Restart Bitbucket

  3. Retry synchronising users

Updated on April 11, 2025

Still need help?

The Atlassian Community is here for you.