Akka-http: Prepare for Akka 2.5

Created on 25 Jan 2017  Â·  21Comments  Â·  Source: akka/akka-http

Akka 2.5 milestone is due soon. To support Akka 2.5 we'll have to figure out a few things:

  • Is Akka 2.5 binary compatible enough, that we can either build just with Akka 2.4 or just with Akka 2.5 and hope that it will work with the other version unchanged?
  • Otherwise, can we cross-compile from one source branch to both versions?

    • How do we set this up for releasing?

    • How do we distinguish versions? By artifact name suffix (akka-http_akka-2.5_2.11) ? By version suffix?

  • Otherwise, do we have to maintain several branches? We really to avoid that.
  • As already shown in #820 we already cannot cross-compile documentation examples between 2.4 and 2.5 any more because of source-incompatible changes in AbstractActor. Do we have to maintain examples for multiple akka versions as well?
docs 1 - triaged 2 - pick next build

Most helpful comment

You need to depend on akka-stream 2.5.0 as well when you want to use akka-actor 2.5.0.

All 21 comments

As 2.5 should be compatible enough, it should be possible to stay on Akka 2.4 for the time being. We should run our tests against 2.5 binary, though. I created #826 to track this.

For documentation examples, we should start to build these against Akka 2.5 as soon as Akka 2.5 is released. We'll then only show Java examples building against Akka 2.5 (but may want to add comments to the examples using AbstractActor to point people to Akka 2.5).

Should we create a specific issue for the java examples using actors?

On Wed, Mar 15, 2017, 17:00 Johannes Rudolph notifications@github.com
wrote:

For documentation examples, we should start to build these against Akka
2.5 as soon as Akka 2.5 is released. We'll then only show Java examples
building against Akka 2.5 (but may want to add comments to the examples
using AbstractActor to point people to Akka 2.5).

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/akka/akka-http/issues/821#issuecomment-286788942, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADLuC725LjsnaKI0ZdpqEzKXArQxIbeIks5rmAsGgaJpZM4LtX0O
.

Yes, could you create one?

Thanks :)

On Mar 27, 2017 3:13 PM, "Josep Prat" notifications@github.com wrote:

Done, #992 https://github.com/akka/akka-http/issues/992

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/akka/akka-http/issues/821#issuecomment-289449275, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAHYk9TAatDQEMxotBnxhBduwtkZ1f8kks5rp7YBgaJpZM4LtX0O
.

Just curious if there is a timeline for getting a release of akka-http out that is compatible with 2.5? Tried running with 2.5 and it threw this exception (probably expected but figured I'd post an update just to be sure...)

Detected java.lang.NoSuchMethodError error, which MAY be caused by incompatible Akka versions on the classpath. Please note that a given Akka version MUST be the same across all modules of Akka that you are using, e.g. if you use akka-actor [2.5.0 (resolved from current classpath)] all other core Akka modules MUST be of the same version. External projects like Alpakka, Persistence plugins or Akka HTTP etc. have their own version numbers - please make sure you're using a compatible set of libraries.
Uncaught error from thread [default-akka.actor.default-dispatcher-4] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.NoSuchMethodError: akka.actor.ActorCell.addFunctionRef(Lscala/Function2;)Lakka/actor/FunctionRef;
    at akka.stream.stage.GraphStageLogic$StageActor.<init>(GraphStage.scala:142)
    at akka.stream.stage.GraphStageLogic.getStageActor(GraphStage.scala:929)
    at akka.stream.impl.io.ConnectionSourceStage$$anon$1.preStart(TcpStages.scala:59)
    at akka.stream.impl.fusing.GraphInterpreter.init(GraphInterpreter.scala:520)
    at akka.stream.impl.fusing.GraphInterpreterShell.init(ActorGraphInterpreter.scala:380)
    at akka.stream.impl.fusing.ActorGraphInterpreter.tryInit(ActorGraphInterpreter.scala:538)
    at akka.stream.impl.fusing.ActorGraphInterpreter.preStart(ActorGraphInterpreter.scala:586)
    at akka.actor.Actor.aroundPreStart(Actor.scala:521)
    at akka.actor.Actor.aroundPreStart$(Actor.scala:521)
    at akka.stream.impl.fusing.ActorGraphInterpreter.aroundPreStart(ActorGraphInterpreter.scala:529)
    at akka.actor.ActorCell.create(ActorCell.scala:583)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:454)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:476)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
    at akka.dispatch.Mailbox.run(Mailbox.scala:223)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
[ERROR] [SECURITY][04/13/2017 10:20:58.135] [default-akka.actor.default-dispatcher-4] [akka.actor.ActorSystemImpl(default)] Uncaught error from thread [default-akka.actor.default-dispatcher-4] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled

build.sbt

name := "akkaHttpTest"

version := "1.0"

scalaVersion := "2.12.1"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.5.0",
  "com.typesafe.akka" %% "akka-http"  % "10.0.5"
)

server.scala

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.Http.ServerBinding
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer

import scala.concurrent.Future

object WebServer {
  def main(args: Array[String]) {
    implicit val system = ActorSystem()
    implicit val materializer = ActorMaterializer()
    implicit val executionContext = system.dispatcher

    val handler = get {
      complete("Hello world!")
    }

    // let's say the OS won't allow us to bind to 80.
    val (host, port) = ("localhost", 80)
    val bindingFuture: Future[ServerBinding] = Http().bindAndHandle(handler, host, port)

    bindingFuture.failed.foreach {
      case ex: Exception => println(s"Failed to bind to $host:$port - $ex")
    }

    sys.addShutdownHook(bindingFuture.foreach(_.unbind().onComplete(_ ⇒ system.terminate())))
  }
}

You need to depend on akka-stream 2.5.0 as well when you want to use akka-actor 2.5.0.

Other than that it should just work.

Ah okay that did it. Thanks for the tip!

Well hopefully if anybody else runs into this they'll see it and know how to fix it ;)

That leads to another point we need to care for when we switch the akka-http build to compile against akka 2.5: we need to prevent or document that this akka-http version might update your akka dependency to 2.5. If you want to keep running with Akka 2.4, you will have to ignore those "transitive version upgrades".

Let's discuss this one again soon, since 2.5 is out.

Is there a real reason someone might want to "stay on 2.4, but use latest http" though?

The risk to deploy a new akka http version in production is probably much less than upgrading Akka itself to 2.5.0 right now.

In fact, the wrongly mixed artifacts problem is not one of akka-http but of akka-stream. We could add a check there (e.g. when creating the ActorMaterializer) which checks that akka-actor and actor-stream versions align.

We could add a check there (e.g. when creating the ActorMaterializer) which checks that akka-actor and actor-stream versions align.

I'm really in favour of adding such checks. I think I attempted some kind of version check some time ago, will dig around tomorrow to remind myself where that was (if it was merged at all or just an idea).

It was https://github.com/akka/akka/pull/22628, though that catches problems only after they have happened.

What about adding some note about checking the right versions of akka-actor and akka-stream on the migration guide?

Have you tried with akka-http 10.0.5? There were some changes there to make
it align with 2.5 better (
http://doc.akka.io/docs/akka-http/10.0.5/release-notes.html#10-0-5 )

On Mon, Apr 24, 2017 at 3:00 PM, PJ Fanning notifications@github.com
wrote:

I tried Akka-Http 10.0.4 with Akka-Stream and Akka-Actor 2.5.0 and got an
a Class Not Found issue.

java.lang.NoClassDefFoundError: akka/stream/Fusing$
at akka.http.scaladsl.HttpExt.fuseServerFlow(Http.scala:87)
at akka.http.scaladsl.HttpExt.bindAndHandle(Http.scala:181)

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/akka/akka-http/issues/821#issuecomment-296659453, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIDEBJ3FKHkgqGcG-3XhaevKmGggqh8ks5rzJz6gaJpZM4LtX0O
.

According to @patriknw in https://github.com/akka/alpakka/pull/311#discussion_r117464467, akka doesn't offer forward compatibility from 2.4 to 2.5. So, strictly speaking, we might lose the guarantee to run akka-http on Akka 2.4 if we compile against Akka 2.5.

We decided not to support Akka 2.4 on the upcoming 10.1.x release line because Akka 2.4 is EOL end of 2017. We'll continue to publish maintenance releases for 10.0.x (if necessary) that will work with Akka 2.4 for about another year.

We'll track the next steps for 10.1.x in #1645. Closing this ticket.

Was this page helpful?
0 / 5 - 0 ratings