Tenant ID not set correctly while using TenantIDProvider as Plugin

Hi all,
Iwant to set the Tenant IDs dynamically by using the TenantIdProvider as a Plugin.

I am currently trying the example from https://docs.camunda.org/manual/latest/user-guide/process-engine/multi-tenancy/#instantiate-a-shared-definition.
Since we are using a shared instance, I was adding the provider as plugin in the bpm-platform.xml:

<!-- plugin enabling tenant Id Provider -->
      <plugin>
        <class>systems.appollo.ams.plugins.CustomTenantIdProvider</class>
      </plugin>

According to the tomcat logs, the provider seems to be recognized by the engine:

13:11:19.956 INFO  {main} [o.c.bpm.engine.cfg] : ENGINE-12003 Plugin 'ProcessApplicationEventListenerPlugin' activated on process engine 'default'
13:11:20.124 INFO  {main} [o.c.bpm.engine.cfg] : ENGINE-12003 Plugin 'systems.appollo.ams.plugins.CustomTenantIdProvider@6221a451' activated on process engine 'default'
13:11:20.174 INFO  {main} [o.c.bpm.engine.cfg] : ENGINE-12003 Plugin 'SpinProcessEnginePlugin' activated on process engine 'default'

But the tenant is never assigned to the shared resource, the tenant ID is always null when starting the process from the camunda cockpit.

Do I have to configure anything else? Below is the implementation of the tenantIDProvider.

Best regards,
Mario

public class CustomTenantIdProvider implements TenantIdProvider, ProcessEnginePlugin {
    private Logger logger = LoggerFactory.getLogger(CustomTenantIdProvider.class.getName());

    @Override
    public String provideTenantIdForProcessInstance(TenantIdProviderProcessInstanceContext tenantIdProviderProcessInstanceContext) {
        return getTenantIdOfCurrentAuthentication();
    }

    @Override
    public String provideTenantIdForCaseInstance(TenantIdProviderCaseInstanceContext tenantIdProviderCaseInstanceContext) {
        return tenantIdProviderCaseInstanceContext.getSuperExecution().getTenantId();
    }

    @Override
    public String provideTenantIdForHistoricDecisionInstance(TenantIdProviderHistoricDecisionInstanceContext tenantIdProviderHistoricDecisionInstanceContext) {
        return tenantIdProviderHistoricDecisionInstanceContext.getExecution().getTenantId();
    }

    protected String getTenantIdOfCurrentAuthentication() {

        IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService();
        Authentication currentAuthentication = identityService.getCurrentAuthentication();

        if (currentAuthentication != null) {

            List<String> tenantIds = currentAuthentication.getTenantIds();
            if (tenantIds.size() == 1) {
                return tenantIds.get(0);

            } else if (tenantIds.isEmpty()) {
                throw new IllegalStateException("no authenticated tenant");

            } else {
                throw new IllegalStateException("more than one authenticated tenant");
            }

        } else {
            throw new IllegalStateException("no authentication");
        }
    }

    @Override
    public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {

    }

    @Override
    public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {

    }

    @Override
    public void postProcessEngineBuild(ProcessEngine processEngine) {

    }
}

Hi @Mario,

please provide a failing test case (i.e. a repository with your custom provider and a JUnit test) to make it easier to analyze the case.

Best regards,
Philipp