Play Authenticate No Context

Hopefully this saves someone a little time.  Starting with a working project that had play authenticate fully integrated and  all of its controller methods fixed to work with 2.4.4/2.4.6 injected routes, I deleted everything but the bare metal code to create an entire application template for future projects.  When trying to pull up the home page, I was getting a runtime error from the controller on construction saying that it could not be injected because there was no http context available.  By removing code from the main page, i quickly determined that the error was coming from the authentication references.  I checked the old application again and everything critical to authentication seemed to be there.  To make a much longer than it should have been story short, the problem was simply that I had not defined an index.html.scala template.  I was using a template named “home” but did not realize that authenticate needed this.  Exactly why would require digging that I don’t care to do, however, in researching the problem, i noticed that in the Global class where I would expect context initialization to happen, the index template was referenced.  So, I added it back with a simple forward to my home page as so

<meta http-equiv=”refresh” content=”0; url=@routes.Application.home” />

and that was all it took.   Anyone interested in this working, starter application please let me know as I will be happy to share it or whatever i’m using for a play starting point at the time.  I am not sure if play authenticate has been updated to be compatible with 2.4.x play yet so this may save  you quite a bit of work.  Hope this helps someone 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *