Monday, 30 September 2013

springSecurityService returns a null user on load

springSecurityService returns a null user on load

Occasionally this code returns a null user object (line 1), even though
the springSecurityService.principal.id is a valid id. Line 2 throws a null
pointer exception because the user object is null. Most of the time the
code works, but I can't figure out what causes the null load.
User user = User.load(springSecurityService.principal.id)
def contactInstance = BasicProfile.findByUser(user)
Attached is a screenshot of the user object after the call in line1.

Could it be due to a timeout in the session? And if so why wouldn't the
controller get redirected to the login page if that were the case?

No comments:

Post a Comment