Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to build and run Apache Kafka 0.8 against Scala 2.9.2 without success

As stated in the topic description, I'm trying to get Kafka 0.8 running with Scala 2.9.2.

I was able to get a working version using the quick start for 0.8 (https://cwiki.apache.org/KAFKA/kafka-08-quick-start.html), but it is compiled against Scala 2.8.0 by default.

I tried to modify the step

./sbt package 

to

./sbt "++2.9.2 package"

it compiles without errors but during start it complains that it cannot find the main class.

/tmp/kafka-8-test/kafka[0.8]$ bin/kafka-server-start.sh onfig/server1.properties
Error: Could not find or load main class kafka.Kafka

Any help will be highly appreciated.

like image 975
twes Avatar asked Dec 11 '22 18:12

twes


2 Answers

kafka-run-class.sh is hard-coded to Scala 2.8.0. You can change 2.8.0 to 2.9.2 as suggested by prenomenon.

This works for me :

  • Linux|Unix

    sed -i "s/2.8.0/2.9.2/g" bin/kafka-run-class.sh

  • MacOS

    sed -i.bak "s/2.8.0/2.9.2/g" bin/kafka-run-class.sh

like image 196
user1779032 Avatar answered May 18 '23 14:05

user1779032


The problem is that the bin/kafka-server-start.sh script uses bin/kafka-run-class.sh to execute the generated jar file.

This script has hard-coded versions, so you need to customize it like this:

...
library=$(echo "$ivyPath/org.scala-lang/scala-library/jars/scala-library-2.9.2.jar")
CLASSPATH=$CLASSPATH:$library

compiler=~$(echo "$ivyPath/org.scala-lang/scala-compiler/jars/scala-compiler-2.9.2.jar")
CLASSPATH=$CLASSPATH:$compiler

log4j=$(echo "$ivyPath/log4j/log4j/jars/log4j-1.2.15.jar")
CLASSPATH=$CLASSPATH:$log4j

slf=$(echo "$ivyPath/org.slf4j/slf4j-api/jars/slf4j-api-1.6.4.jar")
CLASSPATH=$CLASSPATH:$slf

zookeeper=$(echo "$ivyPath/org.apache.zookeeper/zookeeper/jars/zookeeper-3.3.4.jar")
CLASSPATH=$CLASSPATH:$zookeeper

jopt=$(echo "$ivyPath/net.sf.jopt-simple/jopt-simple/jars/jopt-simple-3.2.jar")
CLASSPATH=$CLASSPATH:$jopt

for file in $base_dir/core/target/scala-2.9.2/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

for file in $base_dir/core/lib/*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done

for file in $base_dir/perf/target/scala-2.9.2/kafka*.jar;
do
  CLASSPATH=$CLASSPATH:$file
done
...
like image 28
prenomenon Avatar answered May 18 '23 14:05

prenomenon