Hi there, you're running into "val referring to not yet initialized val" problems.
This can happen if you have traits linearize (http://ktoso.github.io/scala-types-of-types/#type-linearization-vs-the-diamond-problem), in such order that one trait refers with a `val` to another before the first one has a chance to initialize etc. In general if you have a lot of routes refering to one another I'd recommend making them `lazy val` instead. // FYI: This is a general Scala thing, it could happen with "val x = a + b" if b was not yet initialized. Hope this helps, happy hakking! -- Cheers, Konrad 'ktoso’ Malawski Akka @ Lightbend On 24 March 2016 at 20:28:08, Pouria Mellati (pou...@takor.com.au) wrote: I think I've ran into a akka-http bug. I have a big-ass route: val route = pathPrefix("users") { ... } And wanted to add this new route to it: val blockingEndpoint = (pathPrefix("users" / "blocked") & authentication) {issuerId => path(JavaUUID) {blockeeId => put { complete{HttpResponse(NotImplemented)} } ~ delete { complete{HttpResponse(NotImplemented)} } } ~ get { complete{HttpResponse(NotImplemented)} } } Now, if I simply do: val route = pathPrefix("users") { ... } ~ blockingEndpoint I will get the following NPE if I send a request towards the routes in blockingEndpoint: java.lang.NullPointerException: null at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation$$anonfun$$tilde$1$$anonfun$apply$1.apply(RouteConcatenation.scala:28) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation$$anonfun$$tilde$1$$anonfun$apply$1.apply(RouteConcatenation.scala:25) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.util.FastFuture$.akka$http$scaladsl$util$FastFuture$$strictTransform$1(FastFuture.scala:41) ~[akka-http-core-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45) ~[akka-http-core-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.util.FastFuture$.flatMap$extension(FastFuture.scala:26) ~[akka-http-core-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:25) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.RouteConcatenation$RouteWithConcatenation$$anonfun$$tilde$1.apply(RouteConcatenation.scala:23) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$mapRouteResultWith$1$$anonfun$apply$4.apply(BasicDirectives.scala:35) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$mapRouteResultWith$1$$anonfun$apply$4.apply(BasicDirectives.scala:35) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$textract$1$$anonfun$apply$5.apply(BasicDirectives.scala:88) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$textract$1$$anonfun$apply$5.apply(BasicDirectives.scala:88) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$1.apply(ExecutionDirectives.scala:27) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$1.apply(ExecutionDirectives.scala:23) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.Route$$anonfun$asyncHandler$1.apply(Route.scala:64) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.http.scaladsl.server.Route$$anonfun$asyncHandler$1.apply(Route.scala:63) ~[akka-http-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.MapAsync$$anon$9$$anon$10.onPush(Ops.scala:590) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.GraphInterpreter.processElement$1(GraphInterpreter.scala:575) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:586) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:533) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:445) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.GraphInterpreterShell.receive(ActorGraphInterpreter.scala:400) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:549) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.actor.Actor$class.aroundReceive(Actor.scala:480) ~[akka-actor_2.11-2.4.1.jar:na] at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:495) ~[akka-stream-experimental_2.11-2.0.2.jar:na] at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526) [akka-actor_2.11-2.4.1.jar:na] at akka.actor.ActorCell.invoke(ActorCell.scala:495) [akka-actor_2.11-2.4.1.jar:na] at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) [akka-actor_2.11-2.4.1.jar:na] at akka.dispatch.Mailbox.run(Mailbox.scala:224) [akka-actor_2.11-2.4.1.jar:na] at akka.dispatch.Mailbox.exec(Mailbox.scala:234) [akka-actor_2.11-2.4.1.jar:na] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.11.7.jar:na] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.11.7.jar:na] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.11.7.jar:na] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.11.7.jar:na] On the other hand, adding the new routes directly to routes (i.e. without defining blockingEndpoint) works fine: val route = pathPrefix("users") { ... } ~ (pathPrefix("users" / "blocked") & authentication) {issuerId => path(JavaUUID) {blockeeId => put { complete{HttpResponse(NotImplemented)} } ~ delete { complete{HttpResponse(NotImplemented)} } } ~ get { complete{HttpResponse(NotImplemented)} } } My akka version: "2.4.1" My akka streams and http version = "2.0.2" Thanks. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.