Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodException when using reactive Kafka + Avro + Spring Cloud Stream with GraalVM #2962

Open
tamamico opened this issue Feb 7, 2024 · 0 comments

Comments

@tamamico
Copy link

tamamico commented Feb 7, 2024

Hi everyone!

In this repo you have a PoC in which I'm trying to run a native application with Spring Cloud Stream + Kafka Reactive using Avro messages.

If you look at the history, you'll see that I was able to make it run when I used String messages (see pipeline results here), but switching to Avro messages this example only works in a non-native environment (see pipeline results here), but it fails when it tries to run this same test in native with the following exception:

org.apache.kafka.common.KafkaException: Failed to construct kafka producer
org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:459)
org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:287)
org.springframework.kafka.core.DefaultKafkaProducerFactory.createRawProducer(DefaultKafkaProducerFactory.java:913)
org.springframework.kafka.core.DefaultKafkaProducerFactory.createKafkaProducer(DefaultKafkaProducerFactory.java:812)
org.springframework.kafka.core.DefaultKafkaProducerFactory.doCreateProducer(DefaultKafkaProducerFactory.java:779)
[...]
Caused by: org.apache.kafka.common.KafkaException: Could not find a public no-argument constructor for io.confluent.kafka.serializers.KafkaAvroSerializer
org.apache.kafka.common.utils.Utils.newInstance(Utils.java:399)
org.apache.kafka.common.config.AbstractConfig.getConfiguredInstance(AbstractConfig.java:395)
org.apache.kafka.common.config.AbstractConfig.getConfiguredInstance(AbstractConfig.java:434)
org.apache.kafka.common.config.AbstractConfig.getConfiguredInstance(AbstractConfig.java:419)
org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:385)
[...]
Caused by: java.lang.NoSuchMethodException: io.confluent.kafka.serializers.KafkaAvroSerializer.<init>()
java.base@21.0.2/java.lang.Class.checkMethod(DynamicHub.java:1075)
java.base@21.0.2/java.lang.Class.getConstructor0(DynamicHub.java:1238)
java.base@21.0.2/java.lang.Class.getDeclaredConstructor(DynamicHub.java:2930)
org.apache.kafka.common.utils.Utils.newInstance(Utils.java:397)

Please, could you point me in the right direction to solve this problem?

Thanks in advance for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant