RemcoW
RemcoW

Reputation: 4326

Akka cannot start ActorSystem

I've been following the QuickStart guide for Akka Streams and I'm running into an error. My code is simple:

object Main extends App {
  implicit val system = ActorSystem("QuickStart")
  implicit val materializer = ActorMaterializer()

  val source: Source[Int, NotUsed] = Source(1 to 100)
  source.runForeach(i => println(i)) (materializer)
}

However this results in an error:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/Product$class at akka.util.Timeout.(Timeout.scala:13) at akka.actor.ActorSystem$Settings.(ActorSystem.scala:179) at akka.actor.ActorSystemImpl.(ActorSystem.scala:530) at akka.actor.ActorSystem$.apply(ActorSystem.scala:142) at akka.actor.ActorSystem$.apply(ActorSystem.scala:109) at streams_test.Main$.delayedEndpoint$streams_test$Main$1(Main.scala:14) at streams_test.Main$delayedInit$body.apply(Main.scala:13) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App.$anonfun$main$1$adapted(App.scala:76) at scala.collection.immutable.List.foreach(List.scala:378) at scala.App.main(App.scala:76) at scala.App.main$(App.scala:74) at streams_test.Main$.main(Main.scala:13) at streams_test.Main.main(Main.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: java.lang.ClassNotFoundException: scala.Product$class at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 19 more

I've also tried running it through the sbt console with no luck. Does anyone know what's causing this issue? It is being throwed at the line:

implicit val system = ActorSystem("QuickStart")

As requested, my build.sbt file:

name := "Akka_test"

version := "1.0"

scalaVersion := "2.12.0"

// https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor_2.11
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.9"
// https://mvnrepository.com/artifact/com.typesafe.akka/akka-stream_2.11
libraryDependencies += "com.typesafe.akka" % "akka-stream_2.11" % "2.4.12"
// https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core
libraryDependencies += "org.twitter4j" % "twitter4j-core" % "4.0.2"

Upvotes: 1

Views: 6996

Answers (1)

Nagarjuna Pamu
Nagarjuna Pamu

Reputation: 14825

This could be the Scala version problem you might be using the 2.10 compiled library with 2.11 compiler or vice versa.

You can avoid running into the problem if you explicitly have scala version in build.sbt and use %% after groupId in build.sbt

use this

scalaVersion := "scala_version"

libraryDependencies += "group_id" %% "artificat_id" % "version"

instead of

libraryDependencies += "group_id" % "artificat_id_scala_version" % "version"

Upvotes: 11

Related Questions