Solved: Webserver with kafka producer

kafka

#1

Hi,

I’m trying to develop a small web server used for testing only. Currently the web server answers each request with a NOT FOUND response. Everything seems to be OK.

Now I want to change the server so that it sends the contents of each post and put request to a kafka topic. I’ve changed my gradle file and added kafka to my dependencies.

dependencies {
compile group: ‘com.typesafe.akka’, name: ‘akka-http_2.12’, version: ‘10.1.1’
compile group: ‘com.typesafe.akka’, name: ‘akka-stream_2.12’, version: ‘2.5.11’
compile group: ‘org.apache.kafka’, name: ‘kafka_2.11’, version: ‘0.11.0.2’ // <-- new
}

Without changing the source I started the app again. Now I get the following error:

java.lang.NoSuchMethodError: scala.util.parsing.combinator.Parsers.init(Lscala/util/parsing/combinator/Parsers;)V
at com.typesafe.sslconfig.ssl.AlgorithmConstraintsParser$.(Algorithms.scala:246)
at com.typesafe.sslconfig.ssl.AlgorithmConstraintsParser$.(Algorithms.scala)
at com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder.$anonfun$build$1(SSLContextBuilder.scala:107)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.Iterator.foreach(Iterator.scala:929)
at scala.collection.Iterator.foreach$(Iterator.scala:929)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
at scala.collection.IterableLike.foreach(IterableLike.scala:71)
at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike.map(TraversableLike.scala:234)
at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
at scala.collection.AbstractTraversable.map(Traversable.scala:104)
at com.typesafe.sslconfig.ssl.ConfigSSLContextBuilder.build(SSLContextBuilder.scala:107)
at com.typesafe.sslconfig.akka.AkkaSSLConfig.(AkkaSSLConfig.scala:80)
at com.typesafe.sslconfig.akka.AkkaSSLConfig$.createExtension(AkkaSSLConfig.scala:29)
at com.typesafe.sslconfig.akka.AkkaSSLConfig$.createExtension(AkkaSSLConfig.scala:19)
at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:913)
at akka.actor.ExtensionId.apply(Extension.scala:78)
at akka.actor.ExtensionId.apply$(Extension.scala:77)
at com.typesafe.sslconfig.akka.AkkaSSLConfig$.apply(AkkaSSLConfig.scala:24)
at com.typesafe.sslconfig.akka.AkkaSSLConfig$.apply(AkkaSSLConfig.scala:19)
at akka.http.scaladsl.HttpExt.(Http.scala:58)
at akka.http.scaladsl.Http$.createExtension(Http.scala:956)
at akka.http.scaladsl.Http$.createExtension(Http.scala:829)
at akka.actor.ActorSystemImpl.registerExtension(ActorSystem.scala:913)
at akka.actor.ExtensionId.apply(Extension.scala:78)
at akka.actor.ExtensionId.apply$(Extension.scala:77)
at akka.http.scaladsl.Http$.apply(Http.scala:951)
at akka.http.scaladsl.Http$.apply(Http.scala:829)
at akka.http.javadsl.Http.delegate$lzycompute(Http.scala:45)
at akka.http.javadsl.Http.delegate(Http.scala:45)
at akka.http.javadsl.Http.defaultServerHttpContext(Http.scala:826)
at akka.http.javadsl.Http.bind(Http.scala:135)
at akka.http.javadsl.Http.bind(Http.scala:195)
at de.eso.swarm.platform.testing.BaseHttpServer.start(BaseHttpServer.java:168)
at de.eso.swarm.connector.server.LocalTestServer.main(LocalTestServer.java:90)

What can I do to solve this problem?

Thanks in advance

Martin


#2

Hi,

found the solution: I have to exclude a bad dependency from kafka:

compile( group: 'org.apache.kafka', name: 'kafka_2.11', version: '0.11.0.2' ) {
    exclude group: 'org.scala-lang.modules', module: 'scala-parser-combinators_2.11'
}    

Akka loads “scala-parser-combinators_2.12” that works with KAFKA, too.

Have a nice day

Martin


#3

Better solution:

use the same scala version 8-)

    implementation group: 'com.typesafe.akka',  name: 'akka-http_2.11',             version: '10.1.2'
    implementation group: 'com.typesafe.akka',  name: 'akka-stream_2.11',           version: '2.5.11'
    implementation group: 'org.apache.kafka',   name: 'kafka_2.11',                 version: '0.11.0.2'

Hope this helps

Martin