Akka version in Playframework
Asked Answered
P

1

6

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.

Purify answered 20/10, 2015 at 23:28 Comment(0)
K
8

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"
Ketchum answered 21/10, 2015 at 7:34 Comment(3)
That line did not help. Even without it, I see this in the output: [info] Resolving com.typesafe.akka#akka-slf4j_2.11;2.3.13 ... , which indicates that akka-slf4j is already being loaded (and a later version even). This line: libraryDependencies += "com.typesafe.akka" %% "akka-slf4j" % "2.4.0", did make it work. It also had a warning about evicting the 2.3.13 akka-slf4j.Purify
Thank you for the comment - I did update to the answer for the someone who will look laterKetchum
Indeed the akka-slf4j version needs to match... I wonder why this is not part of what gets deployed with the activator template....Communist

© 2022 - 2024 — McMap. All rights reserved.