Zeebe Exporter: ClassCastException with Uber JAR; Lightweight JAR Works Fine

I’ve developed a custom Zeebe exporter and tried packaging it in two ways:

  • :white_check_mark: Lightweight JAR (no dependencies): Works perfectly when added to Zeebe.
  • :x: Uber JAR (with dependencies): Fails at runtime with a ClassCastException.

In some cases, I have external dependencies that my exporter relies on, so I must use a JAR with dependencies. However, using an uber JAR seems to cause classloading issues in Zeebe.

Questions:

  1. Does Zeebe only support lightweight (non-fat) JARs for exporters?
  2. What is the correct or recommended way to include dependencies with a Zeebe exporter to avoid these issues?

Resolved class cast exception, but exporter hasn’t opened.
@jonathan.lukas

Hello @sinugaud ,

the exporter yaml has an issue:

This line should be omitted, the property is zeebe.broker.exporters.<exporterName>, no need to nest exporter inside.

Please see this docs for an example:

Here is an outline on the full configuration:

Best regards,
Jonathan

I’m trying to configure a custom Kafka exporter in my Zeebe broker using the following YAML:

zeebe:
  broker:
    exporters:
      KafkaExporter:
        className: com.example.exporter.kafka.KafkaExporter
        jarPath: /usr/local/zeebe/exporters/zeebe-kafka-exporter.jar

However, I’m encountering the following exception during broker startup:

Caused by: io.camunda.zeebe.broker.exporter.repo.ExporterLoadException: Cannot load exporter [KafkaExporter]: cannot load specified class
Caused by: java.lang.ClassCastException: class com.example.exporter.kafka.KafkaExporter

I also tried renaming the exporter entry to a more generic name like kafka:

zeebe:
  broker:
    exporters:
      kafka:
        className: com.example.exporter.kafka.KafkaExporter
        jarPath: /usr/local/zeebe/exporters/zeebe-kafka-exporter.jar

But I still get the same error:

Caused by: io.camunda.zeebe.broker.exporter.repo.ExporterLoadException: Cannot load exporter [kafka]: cannot load specified class
Caused by: java.lang.ClassCastException: class com.example.exporter.kafka.KafkaExporter

I’m unsure what the exporter name should be in the YAML file based on the class.
I’m not able to figure it out from the current setup.

Can you guide me on how to determine the correct className and what the exporter name should be in the configuration?


Here’s what I’ve observed:
:white_check_mark: If I package the exporter as a lightweight JAR (without dependencies), it works fine.
:x: But when I build a fat JAR (including all dependencies), the Zeebe broker throws a ClassCastException for the exporter class.


Thanks in advance!

Hello @sinugaud ,

please put your exporter api dependency in provided scope to prevent it from being added to your fat jar:

Due to your shading, it will be added to the fat jar, leading to a duplicate Exporter interface class that will not be recognised as the actual exporter class.

Best regards,
Jonathan

I tried with the updated scope, and now I’m no longer getting the ClassCastException when running the fat JAR. However, the exporter still haven’t open — there’s no activity or logs indicating it was picked up.

Any idea what might still be missing?

Hello @sinugaud ,

I would also set your logging stuff to provided scope to ensure the same logger is used.

Best regards,
Jonathan

Thanks Buddy
Its works for me

1 Like