Astarno
Astarno

Reputation: 323

Cannot load play.http.errorHandler

I'm using Play in Scala to develop a website. I've added the following line to my application.conf file in order to include the default error handling:

play.http.errorHandler = play.api.http.HtmlOrJsonHttpErrorHandler

I've done this by advice of the official documentation. However, when I add this line I get the following error:

play.api.PlayException: Cannot load play.http.errorHandler[play.http.errorHandler [play.api.http.HtmlOrJsonHttpErrorHandler] was not loaded.]
at play.utils.Reflect$.loadClass$1(Reflect.scala:111)
at play.utils.Reflect$.configuredClass(Reflect.scala:124)
at play.utils.Reflect$.bindingsFromConfiguration(Reflect.scala:50)
at play.api.http.HttpErrorHandler$.bindingsFromConfiguration(HttpErrorHandler.scala:54)
at play.api.inject.BuiltinModule$$anonfun$$lessinit$greater$1.$anonfun$new$2(BuiltinModule.scala:85)
at play.api.inject.BuiltinModule$$anonfun$$lessinit$greater$1.$anonfun$new$1(BuiltinModule.scala:35)
at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:241)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
Caused by: java.lang.ClassNotFoundException: play.api.http.HtmlOrJsonHttpErrorHandler
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at play.utils.Reflect$.loadClass$1(Reflect.scala:105)
    at play.utils.Reflect$.configuredClass(Reflect.scala:124)
    at play.utils.Reflect$.bindingsFromConfiguration(Reflect.scala:50)
    at play.api.http.HttpErrorHandler$.bindingsFromConfiguration(HttpErrorHandler.scala:54)
    at play.api.inject.BuiltinModule$$anonfun$$lessinit$greater$1.$anonfun$new$2(BuiltinModule.scala:85)
    at play.api.inject.BuiltinModule$$anonfun$$lessinit$greater$1.$anonfun$new$1(BuiltinModule.scala:35)
    at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:241)

Here is a screenshot of what I get when I go to localhost: enter image description here

Any idea why this might be happening and how to fix it?

Upvotes: 0

Views: 469

Answers (1)

Mario Galic
Mario Galic

Reputation: 48400

Comparing changes between Play 2.6.25 and 2.7.0 we deduce that HtmlOrJsonHttpErrorHandler was introduced by Add an HttpErrorHandler that selects the client's preferred media type #8540. The version of Play used in your project should be specified under project/plugins.sbt as something like

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.0")

If you are using 2.6.0 then follow the migration guide to 2.7.

Upvotes: 3

Related Questions