Zeebe exporter class cast exception

Hey guys, I’m working on a custom zeebe exporter. I had some issues with it before

Now my exporter has become a part of a multi module gradle project (I migrated it to maven) and unfortunately on zeebe startup I get this exception

java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:774) [spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:755) [spring-boot-3.1.2.jar:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:319) [spring-boot-3.1.2.jar:3.1.2]
        at io.camunda.zeebe.broker.StandaloneBroker.main(StandaloneBroker.java:82) [camunda-zeebe-8.3.0-alpha4.jar:8.3.0-alpha4]
Caused by: java.lang.IllegalStateException: Failed to load exporter with configuration: ExporterCfg{, jarPath='/usr/local/zeebe/lib/zeebe-exporter-demo-1.0-SNAPSHOT-jar-with-dependencies.jar', className='io.zeebe.exporters.Demo.DemoExporter', args={logLevel=debug, prettyPrint=false}}
        at io.camunda.zeebe.broker.Broker.buildExporterRepository(Broker.java:149) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:70) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:49) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.StandaloneBroker.run(StandaloneBroker.java:91) ~[camunda-zeebe-8.3.0-alpha4.jar:8.3.0-alpha4]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-3.1.2.jar:3.1.2]
        ... 3 more
Caused by: io.camunda.zeebe.broker.exporter.repo.ExporterLoadException: Cannot load exporter [demoexporter]: cannot load specified class
        at io.camunda.zeebe.broker.exporter.repo.ExporterRepository.load(ExporterRepository.java:82) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.buildExporterRepository(Broker.java:147) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:70) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:49) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.StandaloneBroker.run(StandaloneBroker.java:91) ~[camunda-zeebe-8.3.0-alpha4.jar:8.3.0-alpha4]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-3.1.2.jar:3.1.2]
        ... 3 more
Caused by: java.lang.ClassCastException: class io.zeebe.exporters.Demo.DemoExporter
        at java.lang.Class.asSubclass(Unknown Source) ~[?:?]
        at io.camunda.zeebe.broker.exporter.repo.ExporterRepository.load(ExporterRepository.java:80) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.buildExporterRepository(Broker.java:147) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:70) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.Broker.<init>(Broker.java:49) ~[zeebe-broker-8.3.0-alpha4.jar:8.3.0-alpha4]
        at io.camunda.zeebe.broker.StandaloneBroker.run(StandaloneBroker.java:91) ~[camunda-zeebe-8.3.0-alpha4.jar:8.3.0-alpha4]
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-3.1.2.jar:3.1.2]
        ... 3 more

Any thoughts on this one? I’m still building and deploying with java 11 so I hope it’s not a big deal (since Zeebe requires jdk+17). With maven and as a separate module it worked perfectly fine for me.

I was able to trace it in the zeebe codebase that there is a problem with exporter registartion and this is the line throwing exception:

try {
  final Class<?> specifiedClass = classLoader.loadClass(config.getClassName());
  --> exporterClass = specifiedClass.asSubclass(Exporter.class); <---
} catch (final ClassNotFoundException | ClassCastException e) {
  throw new ExporterLoadException(id, "cannot load specified class", e);
}

But I’m almost running out of ideas so any help is appreciated. Thanks.

1 Like

Hey Michal :wave:

Just a guess as the stack trace really doesn’t give away much: Is your exporter compiled with the same version of Zeebe that you are trying to run it with?
I think if your dependency on Zeebe is for example 8.2.12 but you are deploying it to a Zeebe broker in version 8.2.13, you’d get a ClassCastException.

Did you manage to move past this? Running into the same now with Zeebe 8.5.0. Tried compiling the exporter to both jdk 17 and 21, with no success.

1 Like