nodef found org.apache.kafka.common.serialization.stringserializer

Problem

I encountered this error while I was writing: Keycloak: Event Listener SPI & Publish to Kafka

Thread.currentThread().setContextClassLoader(null);

Solution

To resolve this issue. Make your assembly to add the dependency while building the Jar.

<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>Your-jar-name</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Class.forName("org.apache.kafka.common.serialization.stringserializer");

Conclusion

Thank you for reading it. I was able to resolve it by adding the maven assembly plugin. Hope this was useful.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store