What happens, is that the first time I hit the application, I get a null pointer at line:
for(Cookie cookie : request.getCookies())
Which indicates that request == null!!! However, this is strange since there is a guard check before that line
if(request != null)
Therefore, I’m lead to believe that there is a threading/timing issue going on where perhaps the init method is being called before the onRequestStart has finished (or even been called…)
When I refresh the page, it works, in the sense that the request is not null.
but there are cookies - they persist for one week. It wouldn’t explain why on a refresh it works - nothing in my code sets this particular cookie until log in…
But the JSESSIONID cookie is probably set by the server on the first request so on subsequent requests this cookie is available and getCookies() no longer returns null.
EDIT: Use a debugger and see what happens. Then you should find out what really is going on.