Hello,

I'm receiving below exception in my application , *It is still showing me 
the result once though* and application crashes :
This is my code : This failing at *complete :*

Can someone help me on this :


val resFuture = requests.map(x => (getFutureResp(req)))


////////

//// I'm making `complete` on the above resFuture onComplete event.

///////


def getFutureResp(req: HttpRequest)  = {

  val responseFuture = 
Source.single(Http().singleRequest(req)).runWith(Sink.head).flatMap{
    resultFuture => checkRespEntity(resultFuture)
  }

  responseFuture

}


def checkRespEntity(responseFuture: Future[HttpResponse]): Future[Option[Int]] 
= {

  val futureFlags : Future[Option[Int]] = responseFuture.flatMap {
    res =>
      res.status match {
        case StatusCodes.OK =>
          Unmarshal(res.entity).to[String] map {
            info =>
              info.length
              }
              else {
                res.entity.dataBytes.runWith(Sink.ignore)

                None
              }
          }

        case _ =>  {
          res.entity.dataBytes.runWith(Sink.ignore)
          Future{ None }
        }
      }

  }

    futureFlags

}



*Uncaught error from thread [myactor-akka.actor.default-dispatcher-5] 
shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for 
ActorSystem[myactor]*
*java.lang.NoClassDefFoundError: 
akka/http/scaladsl/model/ContentType$WithMissingCharset*
* at 
akka.http.scaladsl.marshalling.Marshal.$anonfun$toResponseFor$2(Marshal.scala:51)*
* at scala.Option.flatMap(Option.scala:171)*
* at 
akka.http.scaladsl.marshalling.Marshal.$anonfun$toResponseFor$1(Marshal.scala:50)*
* at 
akka.http.scaladsl.util.FastFuture$.$anonfun$map$1(FastFuture.scala:23)*
* at 
akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)*
* at 
akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45)*
* at akka.http.scaladsl.util.FastFuture$.map$extension(FastFuture.scala:23)*
* at akka.http.scaladsl.marshalling.Marshal.toResponseFor(Marshal.scala:42)*
* at 
akka.http.scaladsl.marshalling.ToResponseMarshallable.apply(ToResponseMarshallable.scala:17)*
* at 
akka.http.scaladsl.marshalling.ToResponseMarshallable.apply$(ToResponseMarshallable.scala:16)*
* at 
akka.http.scaladsl.marshalling.ToResponseMarshallable$$anon$1.apply(ToResponseMarshallable.scala:22)*
* at 
akka.http.scaladsl.server.RequestContextImpl.complete(RequestContextImpl.scala:42)*
* at 
akka.http.scaladsl.server.directives.RouteDirectives.$anonfun$complete$1(RouteDirectives.scala:47)*
* at 
akka.http.scaladsl.server.StandardRoute$$anon$1.apply(StandardRoute.scala:19)*
* at 
akka.http.scaladsl.server.StandardRoute$$anon$1.apply(StandardRoute.scala:19)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResultWith$2(BasicDirectives.scala:67)*
* at 
akka.http.scaladsl.server.directives.ExecutionDirectives.handle$1(ExecutionDirectives.scala:51)*
* at 
akka.http.scaladsl.server.directives.ExecutionDirectives.$anonfun$handleRejections$4(ExecutionDirectives.scala:60)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$recoverRejectionsWith$1.applyOrElse(BasicDirectives.scala:91)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives$$anonfun$recoverRejectionsWith$1.applyOrElse(BasicDirectives.scala:91)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResultWithPF$1(BasicDirectives.scala:79)*
* at 
akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)*
* at 
akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:45)*
* at 
akka.http.scaladsl.util.FastFuture$.flatMap$extension(FastFuture.scala:26)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$mapRouteResultWith$2(BasicDirectives.scala:67)*
* at 
akka.http.scaladsl.server.directives.BasicDirectives.$anonfun$textract$2(BasicDirectives.scala:154)*
* at 
akka.http.scaladsl.server.directives.ExecutionDirectives.$anonfun$handleExceptions$2(ExecutionDirectives.scala:32)*
* at 
akka.http.scaladsl.server.Route$.$anonfun$asyncHandler$1(Route.scala:79)*
* at akka.stream.impl.fusing.MapAsync$$anon$23.onPush(Ops.scala:1172)*
* at 
akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:499)*
* at 
akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:462)*
* at 
akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:368)*
* at 
akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:571)*
* at 
akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:457)*
* at 
akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:546)*
* at 
akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:725)*
* at 
akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:740)*
* at akka.actor.Actor.aroundReceive(Actor.scala:513)*
* at akka.actor.Actor.aroundReceive$(Actor.scala:511)*
* at 
akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:650)*
* at akka.actor.ActorCell.receiveMessage(ActorCell.scala:527)*
* at akka.actor.ActorCell.invoke(ActorCell.scala:496)*
* at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)*
* at akka.dispatch.Mailbox.run(Mailbox.scala:224)*
* 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)*
*Caused by: java.lang.ClassNotFoundException: 
akka.http.scaladsl.model.ContentType$WithMissingCharset*
* at java.net.URLClassLoader.findClass(URLClassLoader.java:381)*
* at java.lang.ClassLoader.loadClass(ClassLoader.java:424)*
* at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)*
* at java.lang.ClassLoader.loadClass(ClassLoader.java:357)*


Regards,
Aditya Borde

-- 
>>>>>>>>>>      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.

Reply via email to