[play 2.5.1 scala] Exceptions take server down?

626 views
Skip to first unread message

Mike Bryant

unread,
Mar 30, 2016, 6:29:51 PM3/30/16
to play-framework
I've just had a crash caused by my failing to update a dependency (play-mailer) after updating to 2.5.1. This resulted in a NoSuchMethodError when someone tried to send a mail, which is to be expected. However, I did not expect that this would have crashed the whole Play process, with subsequent requests giving the following error:

[error] p.c.s.n.PlayRequestHandler - Exception caught in channelRead future
java
.lang.IllegalStateException: Attempted to call materialize() after the ActorMaterializer has been shut down.
    at akka
.stream.impl.ActorMaterializerImpl.materialize(ActorMaterializerImpl.scala:88)
    at akka
.stream.impl.ActorMaterializerImpl.materialize(ActorMaterializerImpl.scala:79)
    at akka
.stream.scaladsl.RunnableGraph.run(Flow.scala:354)
    at akka
.stream.scaladsl.Source.runWith(Source.scala:93)
    at play
.core.server.netty.NettyModelConversion.createStreamedResponse(NettyModelConversion.scala:237)
    at play
.core.server.netty.NettyModelConversion.convertResult(NettyModelConversion.scala:173)
    at play
.core.server.netty.PlayRequestHandler$$anonfun$play$core$server$netty$PlayRequestHandler$$handleAction$2.apply(PlayRequestHandler.scala:259)
    at play
.core.server.netty.PlayRequestHandler$$anonfun$play$core$server$netty$PlayRequestHandler$$handleAction$2.apply(PlayRequestHandler.scala:255)
    at scala
.util.Success$$anonfun$map$1.apply(Try.scala:237)
    at scala
.util.Try$.apply(Try.scala:192)

I don't recall crashes of this type (NoSuchMethodError or NoClassDefFound) being quite so, erm, final, and taking the entire site down. Has anyone else run into this? Did it happen on 2.4?

Greg Methvin

unread,
Mar 30, 2016, 6:51:00 PM3/30/16
to play-framework
Hi Mike,

NoSuchMethodError, like many other Errors, is generally considered a severe issue with your code that could significantly impair its ability to function as intended. That's why Akka's default supervisor strategy triggers an ActorSystem shutdown in that case. You can of course override it, but I think it's reasonable default behavior. It's hard to know what those kind of errors actually signify and what kind of issues you'd run into if your application tried to keep running.

It should have happened on 2.4 as well (I believe I've run into it before with other types of errors), but you can obviously test it yourself by manually throwing those exceptions.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/aeac1de3-2c1a-4b97-b8ba-75c7d6774560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Senior Software Engineer

Christian Schmitt

unread,
Mar 31, 2016, 2:04:29 AM3/31/16
to play-framework
Actually NoSuchMethodError isn't an Exception. It's an Error:
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it.

A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur. That is, Error and its subclasses are regarded as unchecked exceptions for the purposes of compile-time checking of exceptions.

Reply all
Reply to author
Forward
0 new messages