question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.RuntimeException: io.confluent.kafka.serializers.subject.TopicNameStrategy is not an instance of io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy

See original GitHub issue

Hi,

I’ve been seeing this error intermittently when using fs2-kafka in conjunction with Vulcan. It seems to only happen when used in tests and Fabio has also seen this problem.

I’ve created a simple project where I was able to reproduce the problem: https://github.com/ra-ovo/fs2-kafka-vulcan-issue. There’s a screenshot showing the error and the exception stack trace. To reproduce it had to run SBT in repl mode and hit test a couple of times until I finally got the error. I’ve been trying to explore the problem, without success, on another branch of that repo.

Note that, because I need a schema registry on that test app, I’ve used the docker configuration from the docker-compose.yml file in the project. All of the configurations in the code point to the defaults ports exported by that docker-compose file.

Using sbt-dependency-graph and IntelliJ I saw that there’s a couple of kafka-clients versions showing up: 5.4.0-ccs and 2.4.0 (by using sbt-dependency-graph) and 5.4.0 (when using IntelliJ to open the AbstractKafkaAvroSerDeConfig class, one of the ones that show up in the stack trace).

I’m not entirely sure if this is even a problem on fs2-kafka (on the Vulcan module) or whether anything can be done here, but any hint on how work around this will be very much appreciated.

Please let me know if I can help with this issue.

Thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
sergiojoker11commented, Nov 12, 2021

Sorted. The problem is sbt default class loader layering strategy doesn’t play very well with libraries using reflection. i.e kafka-[avro/schema]-serializer does use reflection. On this scenario, the sbt docs advise to use the Flat strategy. https://www.scala-sbt.org/1.x/docs/In-Process-Classloaders.html#Troubleshooting Therefore, the one liner in the build.sbt fixing the issue is:

[Configuration] / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat

For me Configuration was equal to IntegrationTest. One thing I struggle to understand is why my actual service has not failed the same way if my runDev uses the default sbt class loader layering strategy and the classPath contains the same stuff.

Although I haven’t dived any deeper into the issue, I imagine the class loader was picking up/mixing the SubjectNameStrategy (and its implementations) from kafka-avro-serializer and kafka-schema-serializer since these packages contains copies of said interfaces/classes.

2reactions
bplommercommented, Nov 29, 2020

I ran into this recently - the fix for me was to set run / fork := true in build.SBT

Read more comments on GitHub >

github_iconTop Results From Across the Web

io.confluent.kafka.serializers.subject.TopicNameStrategy is ...
lang.RuntimeException: io.confluent.kafka.serializers.subject.TopicNameStrategy is not an instance of io.confluent.kafka.serializers.subject.strategy.
Read more >
Kafka Connect not working with Subject Strategies
1 Answer 1 ... Source https://docs.confluent.io/current/connect/managing/configuring.html: To pass configuration parameters to key and value ...
Read more >
Schema Registry Serializer and Formatter
The subject name depends on the subject name strategy, which you can set to one of the following three values: TopicNameStrategy ( io.confluent....
Read more >
fd4s/fs2-kafka - Gitter
TopicNameStrategy is not an instance of io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy [info] at io.confluent.common.config.
Read more >
Issue with kafka connect custom name strategy
TopicNameStrategy key.subject.name.strategy = class ... default class: "java.lang.RuntimeException: io.confluent.kafka.serializers.subject.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found