Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play 2.5.3: Cryptic error message: Exception caught in Netty java.lang.NoClassDefFoundError

[error] p.c.s.n.PlayRequestHandler - Exception caught in Netty java.lang.NoClassDefFoundError: Could not initialize class play.api.http.DefaultHttpErrorHandler$ at

I get error message and my app doesn't start in dev mode.

The error doesn't give me any details about what went wrong. I changed log level in logback.xml to DEBUG, but it didn't help.

Any suggestions how to investigate the problem? A week ago it worked just fine and since then there was no any changes in sources and configuration. It stopped working for an unknown reason.

Edit1: How do I enable more verbose logging? Otherwise it's absolutely unclear where the error comes from.

Edit2: changed the title

 (Server started, use Ctrl+D to stop and go back to the console...)

  Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using no
  de.js.
  [error] p.c.s.n.PlayRequestHandler - Exception caught in Netty
  java.lang.NoClassDefFoundError: Could not initialize class play.api.http.DefaultHttpErrorHandler$
          at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:45)
          at play.core.server.Server$class.getHandlerFor(Server.scala:65)
          at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:47)
          at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:82)
          at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:163)
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
          at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:129)
          at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:96)
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
  [error] p.c.s.n.PlayRequestHandler - Exception caught in Netty
  java.lang.NoClassDefFoundError: Could not initialize class play.api.http.DefaultHttpErrorHandler$
          at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:45)
          at play.core.server.Server$class.getHandlerFor(Server.scala:65)
          at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:47)
          at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:82)
          at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:163)
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
          at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:129)
          at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:96)
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
like image 558
Mike Pakhomov Avatar asked May 10 '16 12:05

Mike Pakhomov


2 Answers

I don't know exactly what your problem is, but I encountered this cryptic, unhelpful error when I discovered an error in my application.conf where I was attempting to set a configuration based on an environment variable that may or may not be there. Clearly, the cause of the exception and the place it becomes apparent are pretty far apart.

So I would suggest checking your application.conf for a misconfiguration. Consider also any dependencies that might have been built for Play versions < 2.5. Basically anything that might cause the application to be "mis-initalized" for lack of a better term.

EDIT: I just discovered another cause of this error that falls under the category of "mis-initialization." I changed the name of a route in my routes file but forgot to change the corresponding reverse route in my template. I feel this should be caught sooner and with a more intuitive error, but regardless, look out for this (or something similar) as well in application.conf or routes.

like image 174
Vidya Avatar answered Nov 01 '22 05:11

Vidya


Oops.. java.lang.NoClassDefFoundError: Could not initialize class play.api.http.DefaultHttpErrorHandler$ tells nothing what went wrong. One such reason I have encountered is when I had missing/typos in my configuration properties and use guice injectors.

You can run your app in prod mode to see more informative error message activator clean compile start.

....

[info] Done packaging.

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Oops, cannot start the server. Configuration error: Configuration error[storage.conf @ file:/myproject/mymodule/target/universal/stage/conf/storage.conf: 16: Could not resolve substitution to a value: ${storage.cluster.name}] at play.api.Configuration$.configError(Configuration.scala:154) ....

like image 44
Deepak Avatar answered Nov 01 '22 05:11

Deepak