it could be possible that httpRequest does not have a session. You have to check it and throw exception if session not set.