{"action":"created","issue":{"url":"https://api.github.com/repos/playframework/playframework/issues/4857","repository_url":"https://api.github.com/repos/playframework/playframework","labels_url":"https://api.github.com/repos/playframework/playframework/issues/4857/labels{/name}","comments_url":"https://api.github.com/repos/playframework/playframework/issues/4857/comments","events_url":"https://api.github.com/repos/playframework/playframework/issues/4857/events","html_url":"https://github.com/playframework/playframework/issues/4857","id":95169992,"number":4857,"title":"[2.4.2] Custom java http error handler not trigger","user":{"login":"jCalamari","id":9678999,"avatar_url":"https://avatars.githubusercontent.com/u/9678999?v=3","gravatar_id":"","url":"https://api.github.com/users/jCalamari","html_url":"https://github.com/jCalamari","followers_url":"https://api.github.com/users/jCalamari/followers","following_url":"https://api.github.com/users/jCalamari/following{/other_user}","gists_url":"https://api.github.com/users/jCalamari/gists{/gist_id}","starred_url":"https://api.github.com/users/jCalamari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jCalamari/subscriptions","organizations_url":"https://api.github.com/users/jCalamari/orgs","repos_url":"https://api.github.com/users/jCalamari/repos","events_url":"https://api.github.com/users/jCalamari/events{/privacy}","received_events_url":"https://api.github.com/users/jCalamari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/playframework/playframework/labels/needs%20info","name":"needs info","color":"DDDDDD"},{"url":"https://api.github.com/repos/playframework/playframework/labels/needs-verification","name":"needs-verification","color":"e102d8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-07-15T11:30:33Z","updated_at":"2016-02-19T02:37:11Z","closed_at":null,"body":"Not sure if configuration issue or play issue, so here we go.\r\nI have implemented custom error handler:\r\n\r\n```\r\npackage global;\r\n\r\npublic class CustomHttpErrorHandler implements HttpErrorHandler {\r\n\r\n    @Override\r\n    public F.Promise<Result> onClientError(Http.RequestHeader request, int statusCode, String message) {\r\n        if (statusCode == play.mvc.Http.Status.BAD_REQUEST) {\r\n           // ...\r\n        }\r\n        return null;\r\n    }\r\n\r\n    @Override\r\n    public F.Promise<Result> onServerError(Http.RequestHeader request, Throwable exception) {\r\n        Logger.error(\"Server error\", exception);\r\n        // ...\r\n        return pure(Controller.internalServerError(\"Unexpected exception.\"));\r\n    }\r\n\r\n}\r\n```\r\n\r\nConfigured it in application.conf:\r\n\r\n```\r\nplay {\r\n  // ...\r\n  http {\r\n    errorHandler = \"global.CustomHttpErrorHandler\"\r\n  }\r\n}\r\n```\r\n\r\nAnd I was trying to test it with a restful call to controller throwing runtime exception:\r\n\r\n```\r\npublic class CustomController extends Controller {\r\n\r\n    public Result test() {\r\n        throw new Rollback(\"Rolling back\");\r\n    }\r\n\r\n}\r\n```\r\n\r\nResult: custom java error handler is not triggered, instead scala GlobalSettingsHttpErrorHandler is used. See stacktrace:\r\n\r\n```\r\n[error] application - \r\n\r\n! @6mng3d1oa - Internal server error, for (GET) [/killme] ->\r\n \r\nplay.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[Rollback: Rolling back]]\r\n\tat play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:265) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:191) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.api.GlobalSettings$class.onError(GlobalSettings.scala:179) [play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.api.DefaultGlobal$.onError(GlobalSettings.scala:212) [play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:94) [play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:158) [play-netty-server_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$9$$anonfun$apply$1.applyOrElse(PlayDefaultUpstreamHandler.scala:155) [play-netty-server_2.11-2.4.2.jar:2.4.2]\r\n\tat scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:36) [scala-library.jar:na]\r\n\tat scala.util.Failure$$anonfun$recover$1.apply(Try.scala:215) [scala-library.jar:na]\r\n\tat scala.util.Try$.apply(Try.scala:191) [scala-library.jar:na]\r\nCaused by: models.services.transaction.Rollback: Rolling back\r\n\tat controllers.CustomController.test(CustomController.java:10) ~[classes/:2.4.2]\r\n\tat router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$110$$anonfun$apply$110.apply(Routes.scala:2943) ~[classes/:na]\r\n\tat router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$110$$anonfun$apply$110.apply(Routes.scala:2943) ~[classes/:na]\r\n\tat play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:136) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:127) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.j.JavaAction$$anon$1.call(JavaAction.scala:70) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.http.DefaultHttpRequestHandler$1.call(DefaultHttpRequestHandler.java:20) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:94) ~[play_2.11-2.4.2.jar:2.4.2]\r\n\tat scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library.jar:na]\r\n\r\n```\r\n\r\nBtw, I am using custom `GuiceApplicationLoader` "},"comment":{"url":"https://api.github.com/repos/playframework/playframework/issues/comments/186020814","html_url":"https://github.com/playframework/playframework/issues/4857#issuecomment-186020814","issue_url":"https://api.github.com/repos/playframework/playframework/issues/4857","id":186020814,"user":{"login":"marcospereira","id":4576,"avatar_url":"https://avatars.githubusercontent.com/u/4576?v=3","gravatar_id":"","url":"https://api.github.com/users/marcospereira","html_url":"https://github.com/marcospereira","followers_url":"https://api.github.com/users/marcospereira/followers","following_url":"https://api.github.com/users/marcospereira/following{/other_user}","gists_url":"https://api.github.com/users/marcospereira/gists{/gist_id}","starred_url":"https://api.github.com/users/marcospereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcospereira/subscriptions","organizations_url":"https://api.github.com/users/marcospereira/orgs","repos_url":"https://api.github.com/users/marcospereira/repos","events_url":"https://api.github.com/users/marcospereira/events{/privacy}","received_events_url":"https://api.github.com/users/marcospereira/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T02:37:11Z","updated_at":"2016-02-19T02:37:11Z","body":"Can we close this issue?"}}