Getting started with akka tutorials

72 views
Skip to first unread message

lks...@gmail.com

unread,
Sep 11, 2016, 7:50:58 AM9/11/16
to Akka User List
Hi,

I'm trying to build a rest server with akka-http, but I'm having trouble getting anything to run. I'm still trying to get the tutorials to run, but I'm stuck. What am I missing? Any help would be appreciated. Here's what I tried:

Clone the akka repository:
cd ~/workspace
git clone https://github.com/akka/akka.git


Find the example servers:
cd ~/workspace/akka/akka-docs/rst/java/code/docs/http/javadsl/server

Use jar-files that maven has downloaded previously, and make a classpath string from them:
JARS=".:$(find ~/.m2/repository/{com/typesafe/,org/scala-lang/} -name \*.jar|tr '\n' ':'|sed 's/:$//')"
echo $JARS|sed "s#$HOME#~#g"


These results in:
.:~/.m2/repository/com/typesafe/akka/akka-actor_2.11/2.4.9/akka-actor_2.11-2.4.9.jar:~/.m2/repository/com/typesafe/akka/akka-parsing_2.11/2.4.9/akka-parsing_2.11-2.4.9.jar:~/.m2/repository/com/typesafe/akka/akka-http-core_2.11/2.4.9/akka-http-core_2.11-2.4.9.jar:~/.m2/repository/com/typesafe/akka/akka-stream_2.11/2.4.9/akka-stream_2.11-2.4.9.jar:~/.m2/repository/com/typesafe/akka/akka-http-experimental_2.11/2.4.9/akka-http-experimental_2.11-2.4.9.jar:~/.m2/repository/com/typesafe/ssl-config-core_2.11/0.2.1/ssl-config-core_2.11-0.2.1.jar:~/.m2/repository/com/typesafe/ssl-config-akka_2.11/0.2.1/ssl-config-akka_2.11-0.2.1.jar:~/.m2/repository/com/typesafe/config/1.3.0/config-1.3.0.jar:~/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.11/0.7.0/scala-java8-compat_2.11-0.7.0.jar:~/.m2/repository/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar:~/.m2/repository/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar

Compile the HighLevelServerExample:
/usr/lib/jvm/java-8-openjdk-amd64/bin/javac -classpath ".:$JARS" HighLevelServerExample.java

Execute it from the right directory:
cd ~/workspace/akka/akka-docs/rst/java/code/
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -classpath ".:$JARS" akka.Main docs.http.javadsl.server.HighLevelServerExample


Which gives me:
Exception in thread "main" java.lang.ClassCastException: interface akka.actor.Actor is not assignable from class docs.http.javadsl.server.HighLevelServerExample
    at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(ReflectiveDynamicAccess.scala:23)
    at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(ReflectiveDynamicAccess.scala:20)
    at scala.util.Try$.apply(Try.scala:192)
    at akka.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:20)
    at akka.Main$.main(Main.scala:32)
    at akka.Main.main(Main.scala)


Ivan Vyshnevskyi

unread,
Sep 11, 2016, 11:53:30 AM9/11/16
to akka...@googlegroups.com
Hi,

Removing akka.Main from your last command should help:
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -classpath ".:$JARS" docs.http.javadsl.server.HighLevelServerExample

akka.Main is only required to start your application when all you have is a top-level actor. In this case HighLevelServerExample.java is a main class itself — it has a public static void main() that creates ActorSystemsetups a flow and waits for input on the stdin before shutdown.

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

lks...@gmail.com

unread,
Sep 12, 2016, 1:31:22 PM9/12/16
to Akka User List
Ok,

Obviously there had to be something so basic since it was a tutorial file. I should have read the code with a little more thought and notice that it already had a main-function.

Thanks for pointing out the obvious!
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages