-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Johan,

On 12/17/2009 7:52 AM, Johan Thorselius wrote:
> request.getSession() returns an incorrect null on Linux, but on Windows it's
> OK.

That's odd... request.getSession() should never return null. This method:

"
Returns the current session associated with this request, or if the
request does not have a session, creates one.
"

> I have an ordinary Struts2 web app deployed on Tomcat 6.0.20, together with
> a JAAS-solution where I have my own Valve class.
> 
> The Valve repeatedly executes invoke() with the following code-snippet (here
> very much simplified):
>   .
>   .
>   .
>   if (LOGGER.isDebugEnabled()) {
>     if (request.getSession() == null) {
>       // Log incorrect event (1)
>     } else {
>       // Log OK (2)
>     }
>     if (request.getSession(true) == null) {
>       // Log incorrect event (3)
>     } else {
>       // Log OK (4)
>     }
>   }
> 
>   /*
>    * Here a NullPointerException occurs
>    */
>   request.getSession().setAttribute("...",...);

In the "log incorrect event" code, do you return from the valve, or do
you continue processing?

> In the first request the session is not lost, everything is fine with (2)
> and (4). In the following requests getSession() returns null (1) and (3).

Are you storing the request object anywhere and perhaps using it after
it's been recycled?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksqoSoACgkQ9CaO5/Lv0PDZ7QCfXwdUPAoU9EPxlEC64f11rlAa
+0oAoJG3hjVFYbeCvkrXQ14bkvlq9bJZ
=lF2t
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to