Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka version in Playframework

I am trying integrate some existing code with the play framework. I downloaded the 1.3.6 minimal Typesafe Activator package. I created a play-java project and modified the build.sbt file with these lines:

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

libraryDependencies ++= Seq(
  "com.xxx" % "messages" % "0.0.1-SNAPSHOT"
)

I then added a reference to one of my existing classes in Application.java. When I ran activator run, it downloaded a large number of jars, including the one that I had manually added and successfully compiled the code.

When it tries to run, I get an error:

$ ./activator run
[info] Loading project definition from <APP_ROOT>/project
[info] Set current project to my-proj (in build file:<APP_ROOT>)

--- (Running the application, auto-reloading is enabled) ---

java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLoggingFilter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:67)
    at akka.actor.ReflectiveDynamicAccess$$anonfun$getClassFor$1.apply(DynamicAccess.scala:66)
    at scala.util.Try$.apply(Try.scala:192)
    at akka.actor.ReflectiveDynamicAccess.getClassFor(DynamicAccess.scala:66)
    at akka.actor.ReflectiveDynamicAccess.createInstanceFor(DynamicAccess.scala:84)
    at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:612)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:143)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:127)
    at play.api.libs.concurrent.ActorSystemProvider$.start(Akka.scala:291)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:205)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
    at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
    at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.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:497)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:223)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
    at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)

Looking at version numbers, I think this is because we are using akka-actor 2.4.0-RC2, while activator is using 2.3. Is there a way to get activator to use the 2.4? Or do I need to wait for a new release of activator?

I tried adding

  "com.typesafe.akka" % "akka-actor_2.11" % "2.4.0-RC2"

to libraryDependencies, but that gave a warning about an evicted dependency and the same class not found error.

I am not overly familiar with the interaction between play and activator. If there is a way to make this work by getting rid of one of them without adding a lot of additional work, that is also fine.

like image 881
Troy Daniels Avatar asked Oct 20 '15 23:10

Troy Daniels


People also ask

What is Play and Akka?

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM. On the other hand, Play is detailed as "The High Velocity Web Framework For Java and Scala". Play Framework makes it easy to build web applications with Java & Scala.

Does play use Akka?

Play is built on top of Akka and Akka HTTP, and based on an MVC programming model that should be familiar to many Java and Scala developers. Play focuses on enabling developers to build HTML-based user interfaces.

Is Akka only for Scala?

Akka is written in Scala, with language bindings provided for both Scala and Java.

Is Spark built on Akka?

Apache Spark is actually built on Akka. Akka is a general purpose framework to create reactive, distributed, parallel and resilient concurrent applications in Scala or Java.


1 Answers

I do not think it is the problem with the version. It looks like the problem with the Slf4j.

Try to add akka-slf4j in to the built.sbt:

 libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.3.6"

Update

For the akka actor 2.4.0 you need to add 2.4.0 version of slf4j:

 libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.4.0"
like image 144
Andriy Kuba Avatar answered Sep 29 '22 04:09

Andriy Kuba