Changed thread.session to thread.getSession() to fix concurrency issues.