You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roman Makurin <dr...@gmail.com> on 2010/09/20 09:27:21 UTC
tomcat 5.5, getSession() returns null
Hi all!
We have clustering setup with 2 tomcat 5.5 instances,
and in some cases(eg when clients browser
disable cookies support) behaviour of request.getSession() is
really strange. According to api documentation this
call should always return session object but
it return null.
All URLs r encoded for correct session information, but everytime
user get other page new session id supplied.
Also this situation reproducable only on clustered setup, with
disabled cookies on client side(browser). Everything is ok with
single tomcat instance.
any advise ?
PS: its my first post here, so be patient please :)
PPS: im not an admin of this clustering setup, so not so
much information available.
--
If you think of MS-DOS as mono, and Windows as stereo,
then Linux is Dolby Digital and all the music is free...
Re: tomcat 5.5, getSession() returns null
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Roman,
On 9/21/2010 9:38 AM, Roman Makurin wrote:
> We r using tomcat 5.5.27. Here is server.xml from one of nodes(I skip all not
> important things from my point of view):
>
> <Server port="xxxx" shutdown="SHUTDOWN">
> <Service name="Catalina">
> <Engine name="Catalina" defaultHost="localhost" jvmRoute="apps1">
> <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster" />
> </Engine>
> </Service>
> </Server>
Make sure you have read
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html.
Specifically, this section:
"
NOTE: Use this [above, simple] configuration when you need very quick a
test cluster with at your developer machine. You can change the default
attributes from cluster sub elements. Use following cluster attribute
prefixes sender., receiver., service., manager., valve. and listener..
"
> also in web.xml i dont have <distributable/> tag, only servlet and filters setup
> so it looks like sticky sessions r in use, am i right ?
That's the only way it could work. But it's not working, so perhaps
that's a problem.
> After alot of googling i found some notice about <distributable/>
> tag in web.xml, is there any howto about clustering ?
Clustering is different for every application server. If you are going
to stay with Tomcat 5.5 (no longer actively developed... you might want
to upgrade to Tomcat 7.0), then this is the howto:
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
>> What does your code look like that tried to get the session?
>
> i tried use request.getSession() and request.getSession(true) but with
> the same result
getSession(true) should never return null. Are you getting null or are
you getting a new session?
>> Can you be more specific? Is the server generating a new session id for
>> every request? Please show us how you encode the URLs going back to the
>> client.
>
> Yes, u r exectly right. u used response.encodeURL(), so when cookies r off
> i saw http://host/webapp/somePage.jsp;jsession=sessionId.
Good. If you aren't using distributable sessions, then the sessions are
unlikely to be available on all cluster members. In that case, you must
use sticky sessions.
> And yes, every page come with new session id.
So, if you're on a page with one session id (let's call is SID_A) and
then click on a link that points to http://host/webapp;jsessionid=SID_A,
you end up on a page where all the links have SID_B encoded into their
links?
What happens if you run the cluster with only a single member?
You will need to provide configuration information for whatever you are
using to do your cluster member choosing: a load-balancer or web server
like Apache httpd. What is your setup?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyY5CIACgkQ9CaO5/Lv0PDw0gCeJpyjLrPU10NRNu5RnYxKo4fx
wSsAn3Flxt+09CwlBi1+3snKVfJIw311
=gSPL
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: tomcat 5.5, getSession() returns null
Posted by Roman Makurin <dr...@gmail.com>.
Hi! Thanks for reply!
On Mon, Sep 20, 2010 at 11:30:52AM -0400, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Roman,
>
> On 9/20/2010 3:27 AM, Roman Makurin wrote:
> > We have clustering setup with 2 tomcat 5.5 instances,
>
> What exact version of Tomcat 5.5? Please post your clustering
> configuration, including relevant information from web.xml.
> Specifically, are you using sticky sessions? Distributable sessions?
> What front-end are you using for clustering? Apache httpd or something else?
We r using tomcat 5.5.27. Here is server.xml from one of nodes(I skip all not
important things from my point of view):
<Server port="xxxx" shutdown="SHUTDOWN">
<Service name="Catalina">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="apps1">
<Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster" />
</Engine>
</Service>
</Server>
also in web.xml i dont have <distributable/> tag, only servlet and filters setup
so it looks like sticky sessions r in use, am i right ?
After alot of googling i found some notice about <distributable/>
tag in web.xml, is there any howto about clustering ?
>
> > and in some cases(eg when clients browser
> > disable cookies support) behaviour of request.getSession() is
> > really strange. According to api documentation this
> > call should always return session object but
> > it return null.
>
> Does this only happen when the client doesn't support cookies?
yeah, this situation comes only when im use my app inside of frame
with disabled cookies.
>
> What does your code look like that tried to get the session?
i tried use request.getSession() and request.getSession(true) but with
the same result
>
> > All URLs r encoded for correct session information, but everytime
> > user get other page new session id supplied.
>
> Can you be more specific? Is the server generating a new session id for
> every request? Please show us how you encode the URLs going back to the
> client.
Yes, u r exectly right. u used response.encodeURL(), so when cookies r off
i saw http://host/webapp/somePage.jsp;jsession=sessionId.
And yes, every page come with new session id.
>
> > Also this situation reproducable only on clustered setup, with
> > disabled cookies on client side(browser). Everything is ok with
> > single tomcat instance.
>
> Good to know.
>
> > any advise ?
> >
> > PS: its my first post here, so be patient please :)
> > PPS: im not an admin of this clustering setup, so not so
> > much information available.
>
> You'll need to get that information for us to be helpful.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkyXfiwACgkQ9CaO5/Lv0PCHSgCdG6u5AnBIimGZWFdfZ+sYhQBI
> /JMAn0DD6R7fi34KmmdrUMTILLqk/NNA
> =V6My
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
--
If you think of MS-DOS as mono, and Windows as stereo,
then Linux is Dolby Digital and all the music is free...
Re: tomcat 5.5, getSession() returns null
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Roman,
On 9/20/2010 3:27 AM, Roman Makurin wrote:
> We have clustering setup with 2 tomcat 5.5 instances,
What exact version of Tomcat 5.5? Please post your clustering
configuration, including relevant information from web.xml.
Specifically, are you using sticky sessions? Distributable sessions?
What front-end are you using for clustering? Apache httpd or something else?
> and in some cases(eg when clients browser
> disable cookies support) behaviour of request.getSession() is
> really strange. According to api documentation this
> call should always return session object but
> it return null.
Does this only happen when the client doesn't support cookies?
What does your code look like that tried to get the session?
> All URLs r encoded for correct session information, but everytime
> user get other page new session id supplied.
Can you be more specific? Is the server generating a new session id for
every request? Please show us how you encode the URLs going back to the
client.
> Also this situation reproducable only on clustered setup, with
> disabled cookies on client side(browser). Everything is ok with
> single tomcat instance.
Good to know.
> any advise ?
>
> PS: its my first post here, so be patient please :)
> PPS: im not an admin of this clustering setup, so not so
> much information available.
You'll need to get that information for us to be helpful.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkyXfiwACgkQ9CaO5/Lv0PCHSgCdG6u5AnBIimGZWFdfZ+sYhQBI
/JMAn0DD6R7fi34KmmdrUMTILLqk/NNA
=V6My
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org