I have a Play 2.4 application with a custom error handler with the following signature:
class MyErrorHandler(env: Environment, config: Configuration, sourceMapper: OptionalSourceMapper, router: () => Router, mailer: Mailer)
extends DefaultHttpErrorHandler(env, config, sourceMapper, new Provider[Router] {def get() = router()})
Note the Mailer as the last parameter in the constructor. I have bound Mailer and the custom handler like this:
bind[Mailer] when inProdMode to new ProdMailer
bind[Mailer] when inDevMode to new MockMailer
bind [HttpErrorHandler] to injected [MyErrorHandler] ('router -> injectProvider[Router])
The problem is I get a StackOverflowError on startup with this setup. If I remove the mailer from the methods where I use it but keep it in the constructor, the application starts just fine. Only when the mailer does something do I get the error.
Can anyone tell me where I messed up my bindings?
Thanks.