Session handling, Session still invalidated when trying to log in

I have an application using form based security with JSF on SJAS.

Loggin in the first time works fine and I log out the user with:

<%

session.invalidate();

session = request.getSession(true);

response.sendRedirect("main.faces");

return;

%>

Which redirects him to the log in page again, which is good. The only problem is that when the user logs in again I try to set the user attributes with:

session = request.getSession(true);

session.setAttribute("userid","5");

And this results in a crash with the message:

Servlet.service() for servlet Faces Servlet threw exception

java.lang.IllegalStateException: getAttribute: Session already invalidated

at org.apache.catalina.session.StandardSession.getAttribute(StandardSession.java:1113)

(I'm not sure these are the lines causing the crash but they are the ones first in the JSP page, it could be that the crash is caused by the SJAS security mechanism)

Anyone has any idea to what is causing this? Shouldn't request.getSession(true); result in a new fresh session that is not invalidated?

Thanks for any help!

/Richard

[1187 byte] By [ricarlssona] at [2007-11-27 9:57:50]
# 1
hi,me not having idea abt jsf,but i give link to know how to handle sessions what i post previously, http://forum.java.sun.com/thread.jspa?threadID=5190742
drvijayy2k2a at 2007-7-13 0:28:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
java.lang.IllegalStateException: getAttribute: Session already invalidatedLook at the message again: you're trying to use getAttribute() while the session is invalidated.I don't see getAttribute() in your coding examples, only setAttribute(). Please debug your code once
BalusCa at 2007-7-13 0:28:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hi,

Thanks for your answers!

I know that it has something to do with getAttribute, the problem is that I have removed all calls to that method in my code. In fact I have removed all code that sets or gets from the session but it still gives me the same error when the user tries to log in again (using form based login on SJAS).

The result is that you can never log in again once you have logged out. Could this have something to do with how security is set up?

/Richard

ricarlssona at 2007-7-13 0:28:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...