tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: tomcat 5.5, getSession() returns null
Date Tue, 21 Sep 2010 16:58:10 GMT
Hash: SHA1


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
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:

>> 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

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
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message