Re: [akka-user] Uncaught error from thread - ContentType$WithMissingCharset

155 views
Skip to first unread message

Konrad “ktoso” Malawski

unread,
Oct 10, 2017, 9:04:22 PM10/10/17
to akka...@googlegroups.com, bord...@gmail.com
The exception is pretty clear about something being wrong with dependencies:

> java.lang.NoClassDefFoundError: akka/http/scaladsl/model/ContentType$WithMissingCharset

How do you configure this project? 
What’s your dependencies / build file / build system?

Konrad `kto.so` Malawski

On 11 October 2017 at 10:02:49, bord...@gmail.com (bord...@gmail.com) wrote:

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

}


  
  futureFlags
}

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

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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

bord...@gmail.com

unread,
Oct 10, 2017, 9:15:27 PM10/10/17
to Akka User List
Thanks for quick reply, Konrad.

Actually, I'm using - these json parsing dependencies in Gradle.

compile group: 'org.json4s', name: 'json4s-native_2.12', version: '3.2.11'
compile group: 'org.json4s', name: 'json4s-jackson_2.12', version: '3.5.0.RC1'
compile group: 'de.heikoseeberger', name: 'akka-http-json4s_2.12', version: '1.17.0'

And, I modified the function actually, where I'm using jackson.parseJson(info) like this -

Unmarshal(res.entity).to[String] map {
info =>
              jackson.parseJson(info).children.length
Am I doing something wrong here?  or something wrong in Parsing using json4s?

Regards,
Aditya Borde

Konrad “ktoso” Malawski

unread,
Oct 10, 2017, 9:17:49 PM10/10/17
to akka...@googlegroups.com, bord...@gmail.com
Actually depend on akka-http 10.0.10 and akka 2.5.6 ;-)

Konrad `kto.so` Malawski

bord...@gmail.com

unread,
Oct 10, 2017, 9:22:16 PM10/10/17
to Akka User List
Ok. I'm currently using 
akkaHttp: "10.0.7", akka: "2.5.2". Is there an issue? Or What packages I should be using?



bord...@gmail.com

unread,
Oct 10, 2017, 9:28:08 PM10/10/17
to Akka User List
Even I'm surprised, it is working fine for many requests if I fire it from Firefox and crashes with the above error after like 5-6 requests made.

But , in Chrome it crashes with the same error after 1st request itself (showing me the output).

Regards,
Aditya Borde

Konrad “ktoso” Malawski

unread,
Oct 11, 2017, 12:00:40 AM10/11/17
to akka...@googlegroups.com, bord...@gmail.com
Weird indeed;

With regards to versions, please always use the latest - esp when reporting issues like this.
Please try 10.0.10 and 2.5.6 as I suggested above.

Can you post a reproducer (repository) where we could reproduce this?

Konrad `kto.so` Malawski

bord...@gmail.com

unread,
Oct 11, 2017, 11:27:06 AM10/11/17
to Akka User List
Hi Konrad,

I think, the above VERSIONS resolved my issue. Thank you very much for the response. I tested my code and it is working now.
(I'm working for a company so, hard to share the code.)


Regards,
Aditya Borde

Konrad “ktoso” Malawski

unread,
Oct 11, 2017, 11:35:10 AM10/11/17
to akka...@googlegroups.com, bord...@gmail.com
Happy hakking, cheers :)

Konrad `kto.so` Malawski

Reply all
Reply to author
Forward
0 new messages