javajava-8apache-kafkajava-12

Kafka unable to resolve javax/xml/bind/* ClassNotFoundExeption for java 12?


I'm learning kafka and just downloaded kafka 0.10.1 (as it's the requirement of my project) and whenever i run this command line code

bin/kafka-server-start.sh config/server.properties

i get this error

java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    at kafka.utils.CoreUtils$.urlSafeBase64EncodeNoPadding(CoreUtils.scala:298)
    at kafka.utils.CoreUtils$.generateUuidAsBase64(CoreUtils.scala:286)
    at kafka.server.KafkaServer$$anonfun$getOrGenerateClusterId$1.apply(KafkaServer.scala:336)
    at kafka.server.KafkaServer$$anonfun$getOrGenerateClusterId$1.apply(KafkaServer.scala:336)
    at scala.Option.getOrElse(Option.scala:121)
    at kafka.server.KafkaServer.getOrGenerateClusterId(KafkaServer.scala:336)
    at kafka.server.KafkaServer.startup(KafkaServer.scala:203)
    at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:39)
    at kafka.Kafka$.main(Kafka.scala:67)
    at kafka.Kafka.main(Kafka.scala)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 10 more

I'm actually using java 12 and javax/xml/bind/* is removed from java 11 so some suggestion were to add the dependencies in the pom.xml file but i unzipped kafka from a .tar file and not build it using maven so how can i resolve this error in kafka??

should i download java-8 for this??


Solution

  • I'm learning kafka and just downloaded kafka 0.10.1

    This version of Kafka does not support versions of Java above 8.

    Only the newest Kafka 2.2.0 (which very likely will work the same for your learning purposes), added support for Java 11