pekko icon indicating copy to clipboard operation
pekko copied to clipboard

Error materializing flow

Open samirbajaj opened this issue 3 years ago • 6 comments

I ported my app from Akka 2.6 to pekko (see below for snapshot versions), and although I am able to build it successfully, I am seeing this runtime error -- strangely enough a ClassCastException between pekko and akka:

[ERROR] [05/11/2023 11:19:38.017] [some-actor-system-pekko.actor.default-dispatcher-11] [org.apache.pekko.actor.ActorSystemImpl(tungsten-actor-system)] Could not materialize handling flow for IncomingConnection(/127.0.0.1:19000,/127.0.0.1:52055,Flow(FlowShape(IncomingTCP.in(1076416245),GraphStages$Detacher$.out(250680658))))
java.lang.ClassCastException: class org.apache.pekko.http.ParsingErrorHandler is not assignable from class akka.http.DefaultParsingErrorHandler$
	at org.apache.pekko.actor.ReflectiveDynamicAccess.$anonfun$getClassFor$1(ReflectiveDynamicAccess.scala:41)
	at scala.util.Try$.apply(Try.scala:213)
	at org.apache.pekko.actor.ReflectiveDynamicAccess.getClassFor(ReflectiveDynamicAccess.scala:38)
	at org.apache.pekko.actor.ReflectiveDynamicAccess.createInstanceFor(ReflectiveDynamicAccess.scala:57)
	at org.apache.pekko.http.impl.settings.ServerSettingsImpl.parsingErrorHandlerInstance(ServerSettingsImpl.scala:69)
	at org.apache.pekko.http.impl.engine.server.HttpServerBluePrint$ControllerStage$$anon$9.<init>(HttpServerBluePrint.scala:428)
	at org.apache.pekko.http.impl.engine.server.HttpServerBluePrint$ControllerStage.createLogicAndMaterializedValue(HttpServerBluePrint.scala:426)
	at org.apache.pekko.stream.impl.GraphStageIsland.materializeAtomic(PhasedFusingActorMaterializer.scala:709)
	at org.apache.pekko.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:508)
	at org.apache.pekko.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:458)
	at org.apache.pekko.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:450)
	at org.apache.pekko.stream.scaladsl.RunnableGraph.run(Flow.scala:774)
	at org.apache.pekko.http.scaladsl.HttpExt.$anonfun$bindAndHandle$1(Http.scala:269)
	at org.apache.pekko.stream.impl.fusing.MapAsyncUnordered$$anon$31.onPush(Ops.scala:1443)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:555)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:506)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:400)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:662)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:532)
	at org.apache.pekko.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:637)
	at org.apache.pekko.stream.impl.fusing.ActorGraphInterpreter.org$apache$pekko$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:813)
	at org.apache.pekko.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:831)
	at org.apache.pekko.actor.Actor.aroundReceive(Actor.scala:547)
	at org.apache.pekko.actor.Actor.aroundReceive$(Actor.scala:545)
	at org.apache.pekko.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:729)
	at org.apache.pekko.actor.ActorCell.receiveMessage(ActorCell.scala:590)
	at org.apache.pekko.actor.ActorCell.invoke(ActorCell.scala:557)
	at org.apache.pekko.dispatch.Mailbox.processMailbox(Mailbox.scala:280)
	at org.apache.pekko.dispatch.Mailbox.run(Mailbox.scala:241)
	at org.apache.pekko.dispatch.Mailbox.exec(Mailbox.scala:253)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)

I'm on Scala 2.12. Here are the pekko dependencies:

lazy val pekkoSettings = Seq(
  libraryDependencies ++= Seq(

    "org.apache.pekko" %% "pekko-actor"            % "0.0.0+26550-2fc481bc-SNAPSHOT",
    "org.apache.pekko" %% "pekko-slf4j"            % "0.0.0+26549-195904f2-SNAPSHOT",
    "org.apache.pekko" %% "pekko-connectors-kafka" % "0.0.0+1715-d36a8e1a-SNAPSHOT",
    "org.apache.pekko" %% "pekko-http"             % "0.0.0+4270-1cfacad4-SNAPSHOT",
    "org.apache.pekko" %% "pekko-http-spray-json"  % "0.0.0+4270-1cfacad4-SNAPSHOT",
    "org.apache.pekko" %% "pekko-stream"           % "0.0.0+26550-2fc481bc-SNAPSHOT",

    "com.github.swagger-akka-http" %% "swagger-pekko-http" % "2.10.0+13-ec2a1564-SNAPSHOT",
    "com.github.swagger-akka-http" %% "swagger-scala-module" % "2.9.1",
    "com.github.swagger-akka-http" %% "swagger-enumeratum-module" % "2.6.1",

    "org.apache.pekko" %% "pekko-testkit"                  % "0.0.0+26546-767209a8-SNAPSHOT" % Test,
    "org.apache.pekko" %% "pekko-stream-testkit"           % "0.0.0+26546-767209a8-SNAPSHOT" % Test,
    "org.apache.pekko" %% "pekko-http-testkit"             % "0.0.0+4270-1cfacad4-SNAPSHOT"  % Test,
    "org.apache.pekko" %% "pekko-connectors-kafka-testkit" % "0.0.0+1717-267012de-SNAPSHOT"  % Test
  )
)

What did I miss?

Thank you for your help.

samirbajaj avatar May 11 '23 19:05 samirbajaj

Check your config files (application.conf - for instance). Those files can include class names as config values. You might have left over 'akka' values.

pjfanning avatar May 11 '23 19:05 pjfanning

The pekko-http reference.conf has https://github.com/apache/incubator-pekko-http/blob/54c9b20c48b02b9c62fc903984c09a92bbc6a12b/http-core/src/main/resources/reference.conf#L199

So it is not pekko-http reference.conf that is providing the 'akka.http.DefaultParsingErrorHandler$' value.

pjfanning avatar May 11 '23 19:05 pjfanning

This is very interesting ... I'm building an assembly, and one of the reference.conf files being pulled in is the following:

########################################
# akka-http-core Reference Config File #
########################################

# This is the reference config file that contains all the default settings.
# Make your edits/overrides in your application.conf.

# Akka HTTP version, checked against the runtime version of Akka HTTP.
# Loaded from generated conf file.
include "pekko-http-version"

akka.http {

  server {
    # The default value of the `Server` header to produce if no
    # explicit `Server`-header was included in a response.
    # If this value is the empty string and no header was included in
    # the request, no `Server` header will be rendered at all.
    server-header = pekko-http/${pekko.http.version}

    # "PREVIEW" features that are not yet fully production ready.
    # These flags can change or be removed between patch releases.
    preview {
      # If this setting is enabled AND the akka-http2-support is found
      # on the classpath, `Http().newServerAt(...).bind` and `bindSync`
      # will be enabled to use HTTP/2.
      #
      # `Http().newServerAt(...).bindFlow` and `connectionSource()` are not supported.
      enable-http2 = off
    }

...

Notice that the block begins with akka.http but references pekko all over the place. Is that how it is supposed to be?

samirbajaj avatar May 11 '23 20:05 samirbajaj

try upgrading the pekko snapshots - maybe you have an early pekko-http snapshot from before we finished all the code changes

maybe have a look at https://github.com/pjfanning/swagger-pekko-http-sample - that works fine

pjfanning avatar May 11 '23 20:05 pjfanning

No word on this from OP. Information has been provided. Please reopen if there is a reproducible test case that can be investigated. There are examples and tests that show this to be working (at least in those scenarios).

pjfanning avatar May 26 '23 12:05 pjfanning

Thank you for your help @pjfanning

samirbajaj avatar May 26 '23 14:05 samirbajaj