Custom Interceptor not working

I am trying to load my ZeebeTenantInterceptor under path - zeebe:/usr/local/zeebe/lib of my local docker setup.

@Override
public <ReqT, RespT> ServerCall.Listener interceptCall(
final ServerCall<ReqT, RespT> call,
final Metadata headers,
final ServerCallHandler<ReqT, RespT> next) {
System.out.println(“Interceptor Started”);
final List authorizedTenantIds = List.of(“tenant-a”);
final Context context = Context.current();
context.withValue(InterceptorUtil.getAuthorizedTenantsKey(), authorizedTenantIds);
System.out.println(“Interceptor Exited”);
return Contexts.interceptCall(context, call, headers, next);
}

I followed docs and created a fat jar and then pushing this under above zeebe location. Currently I am only authorizing one tenant i.e tenant-a for the sake of test.

Now when I add the jar and rerun my docker setup I am able to see the interceptor logs with all calls but when I am trying to execute below standalone java code i am getting error.

CODE:
public final class ProcessDeployer {
private static final Context.Key TENANT_KEY = Context.key(“tenant”);

public static void main(final String args) {
final String defaultAddress = “localhost:26500”;
final String envVarAddress = System.getenv(“ZEEBE_ADDRESS”);

final ZeebeClientBuilder clientBuilder;
if (envVarAddress != null) {
  /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
   * See JavaDoc on class level for details
   */
  clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
} else {
  // connect to local deployment; assumes that authentication is disabled
  clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
}

try (final ZeebeClient client = clientBuilder.build()) {

  final DeploymentEvent deploymentEvent =
      client
          .newDeployResourceCommand()
          .addResourceFromClasspath("demoProcess.bpmn")
          .tenantId("tenant-a")
          .send()
          .join();

  System.out.println("Deployment created with key: " + deploymentEvent.getKey());
}

}
}

ERROR:
Exception in thread “main” io.camunda.zeebe.client.api.command.ClientStatusException: Expected to handle gRPC request DeployResource with tenant identifier ‘tenant-a’, but tenant could not be retrieved from the request context
at io.camunda.zeebe.client.impl.ZeebeClientFutureImpl.transformExecutionException(ZeebeClientFutureImpl.java:116)
at io.camunda.zeebe.client.impl.ZeebeClientFutureImpl.join(ZeebeClientFutureImpl.java:54)
at io.camunda.zeebe.example.process.ProcessDeployer.main(ProcessDeployer.java:60)
Caused by: java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Expected to handle gRPC request DeployResource with tenant identifier ‘tenant-a’, but tenant could not be retrieved from the request context
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
at io.camunda.zeebe.client.impl.ZeebeClientFutureImpl.join(ZeebeClientFutureImpl.java:52)
… 1 more
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Expected to handle gRPC request DeployResource with tenant identifier ‘tenant-a’, but tenant could not be retrieved from the request context
at io.grpc.Status.asRuntimeException(Status.java:533)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:481)
at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

Process finished with exit code 1

Followed example - camunda-8-examples/zeebe-client-plain-java/src/main/java/io/camunda/zeebe/example/process/ProcessDeployer.java at e1bc390a3dc9981b39ec864decd52ebe12fab049 · camunda-community-hub/camunda-8-examples · GitHub

Is there any way to deploy a process using the tenant i.e tenant-a which I have authorized under ZeebeTenantInterceptor?

Attaching my docker-compose.yaml as well for ref.
docker-compose-core.yaml (5.0 KB)

Zeebe Logs -
Interceptor Started
Interceptor Exited
2024-05-29 09:11:13.135 [grpc-executor-0] DEBUG
io.camunda.zeebe.gateway - Expected to handle gRPC request DeployResource with tenant identifier ‘tenant-a’, but tenant could not be retrieved from the request context
io.camunda.zeebe.gateway.cmd.InvalidTenantRequestException: Expected to handle gRPC request DeployResource with tenant identifier ‘tenant-a’, but tenant could not be retrieved from the request context
at io.camunda.zeebe.gateway.RequestMapper.ensureTenantIdSet(RequestMapper.java:354) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.RequestMapper.toDeployResourceRequest(RequestMapper.java:104) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.EndpointManager.mapToBrokerRequest(EndpointManager.java:489) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.EndpointManager.sendRequest(EndpointManager.java:430) [zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.EndpointManager.deployResource(EndpointManager.java:270) [zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.GatewayGrpcService.deployResource(GatewayGrpcService.java:131) [zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.protocol.GatewayGrpc$MethodHandlers.invoke(GatewayGrpc.java:2312) [zeebe-gateway-protocol-impl-8.5.0.jar:8.5.0]
at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) [grpc-stub-1.62.2.jar:1.62.2]
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:351) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:861) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) [grpc-core-1.62.2.jar:1.62.2]
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:?]
Interceptor Started
Interceptor Exited
2024-05-29 09:11:13.801 [grpc-executor-0] DEBUG
io.camunda.zeebe.gateway - Expected to handle gRPC request ActivateJobs with tenant identifier ‘’, but tenant could not be retrieved from the request context
io.camunda.zeebe.gateway.cmd.InvalidTenantRequestException: Expected to handle gRPC request ActivateJobs with tenant identifier ‘’, but tenant could not be retrieved from the request context
at io.camunda.zeebe.gateway.RequestMapper.ensureTenantIdSet(RequestMapper.java:354) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.RequestMapper.lambda$ensureTenantIdsSet$0(RequestMapper.java:377) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source) ~[?:?]
at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source) ~[?:?]
at io.camunda.zeebe.gateway.RequestMapper.ensureTenantIdsSet(RequestMapper.java:377) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.RequestMapper.toActivateJobsRequest(RequestMapper.java:229) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.EndpointManager.mapToBrokerRequest(EndpointManager.java:489) ~[zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.EndpointManager.activateJobs(EndpointManager.java:188) [zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.GatewayGrpcService.activateJobs(GatewayGrpcService.java:67) [zeebe-gateway-8.5.0.jar:8.5.0]
at io.camunda.zeebe.gateway.protocol.GatewayGrpc$MethodHandlers.invoke(GatewayGrpc.java:2280) [zeebe-gateway-protocol-impl-8.5.0.jar:8.5.0]
at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) [grpc-stub-1.62.2.jar:1.62.2]
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) [grpc-api-1.62.2.jar:1.62.2]
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:351) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:861) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) [grpc-core-1.62.2.jar:1.62.2]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) [grpc-core-1.62.2.jar:1.62.2]
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) [?:?]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) [?:?]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.