title: JSF and Tomcat: getSession and getRequestedSessionId return null
body: <p>I have a web application that has a phase listener. When the phase listener runs, it does a few things with the session map. Randomly (usually not the firs request, but more frequently when requests are issued quickly) I am getting a null pointer exception from SessionMap.put. After a bit of digging it appeared that when SessionMap.put was getting the session, it was getting back a null pointer (even though it calls getSession(true)). So I did a bit of debugging and discovered that indeed getSession and getRequestedSessionId are both returning null when invoked. However, if you check the cookies in the request (request.getCookies()) the JSESSIONID cookie is included in the request and has the correct session. There doesn't seem to be rhyme or reason as to why the session and the requested session id some times comes back normal and sometimes comes back null. The only other piece of information that might be relevant here is that the JSF pages are living within the same application that some older JSP/Servlets are living in.</p>
  
  <p>I've looked around online and others have said setting the cookie path to "/" has solved similar issues for them, but it doesn't appear to solve the issue here.</p>