You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Varley, Roger" <Ro...@atosorigin.com> on 2007/01/03 17:57:10 UTC

Strange behaviour after upgrade to 5.5.20

Hi

I've been undertaking a major tomcat upgrade, moving from Tomcat 4.1.31 running on Win NT with IIS 1.2 to Tomcat 5.5.20 running on Win 2003 Server with IIS 6.0. I'm just about there, but I've got a problem with a servlet that runs fine under the old setup but exhibits strange behaviour under the new setup. It seems to be to do with session managent under Tomcat 5.5.20 - has the way sessions and session data is handled changed - and if so can someone point me to relevant documentation.

Thanks

Roger Varley

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted. 
_______________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Strange behaviour after upgrade to 5.5.20

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roger,

Varley, Roger wrote:
> I've finally sussed it. Because we're still in development, we've 
> been fairly cavalier about how we've been calling the initial servlet
> (as localhost/servlet, hostname/servlet and by IP address/servlet)
> and some of the links within the application have been using a
> mixture of IP addresses and hostname).

That in itself shouldn't be a big problem.

> It appears that Tomcat is
> creating a seperate session based on the "host" portion of the URL
> that its being passed.

Nope. Tomcat creates sessions when you need one. If you are swithing
server names, then your browser is not submitting the cookie that is
likely to be used for session tracking. If you were using URL rewriting
instead of cookies, my guess is that you never would have known that
there was a problem.

> So when we called the servlet initially using,
> for example, http://123.123.123.123/servlet and loaded the session
> data, a subsequent call to http://hostname/servlet created a new
> session - hence the appearance of sessions going out of sync.

Yup. Your browser stopped sending the cookie (because of the hostname
change) and so you "lost" your session. On the bright side, you got
yourself a new one!

> Now we've standardised and everything is working as expected.

That's always best. I hope you mean that the application itself has been
standardized, instead of the method of access.

> Is this a known behaviour or is there something we can do through
> config to get around this problem?

Tomcat doesn't mess with your URLs. If you emit a URL to your client
browser with the address 123.123.123.123, then that's what the client is
going to get.

On the other hand, if you let your content delivery tools (JSP taglibs
or something similar) do the work of emitting URLs for you, you should
never have to worry about this kind of thing. Those tools are written so
that they either emit relative URLs (which have no hostname information
in them, so there's no confusion), or they emit fully-qualified URLs
containing the hostname that is currently being used to access the
webapp, which should therefore never change.

I wouldn't recommend hard-coding the hostname anywhere in your webapp.
You never know when you are going to have to re-deploy the app into a
separate environment. If you have hard-coded the hostname, then you'll
have to go back into the code and recompile in order to re-deploy.

I hope that clears things up,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFnmK/9CaO5/Lv0PARAgGAAKDD2u0ECd0IZfT7Zl6PBP2t9QxYZwCfSf1r
tC4C6BVXVJ1vlVJcXh5CGbE=
=3r+A
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Strange behaviour after upgrade to 5.5.20

Posted by "Varley, Roger" <Ro...@atosorigin.com>.
> 
> Hi
> 
> I've been undertaking a major tomcat upgrade, moving from 
> Tomcat 4.1.31 running on Win NT with IIS 1.2 to Tomcat 5.5.20 
> running on Win 2003 Server with IIS 6.0. I'm just about 
> there, but I've got a problem with a servlet that runs fine 
> under the old setup but exhibits strange behaviour under the 
> new setup. It seems to be to do with session managent under 
> Tomcat 5.5.20 - has the way sessions and session data is 
> handled changed - and if so can someone point me to relevant 
> documentation.
> 

Actually the previous suggestions didn't fix it. I've finally sussed it. Because we're still in development, we've been fairly cavalier about how we've been calling the initial servlet (as localhost/servlet, hostname/servlet and by IP address/servlet) and some of the links within the application have been using a mixture of IP addresses and hostname). It appears that Tomcat is creating a seperate session based on the "host" portion of the URL that its being passed. So when we called the servlet initially using, for example, http://123.123.123.123/servlet and loaded the session data, a subsequent call to http://hostname/servlet created a new session - hence the appearance of sessions going out of sync. Now we've standardised and everything is working as expected.

Is this a known behaviour or is there something we can do through config to get around this problem?

Regards
Roger 

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted. 
_______________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Strange behaviour after upgrade to 5.5.20

Posted by Gregor Schneider <rc...@googlemail.com>.
Well, haven't looked at the code of either version (4.x, 5.x),
however, I figured that 5.x makes a bit more use of Java's
threading-features. Besides, unsynchronized hashmaps are a
#1-candidate for errors that are either strange, not reproducible and
in cases where you think you should file a bug-report ;)

Cheers

Greg
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Strange behaviour after upgrade to 5.5.20

Posted by "Varley, Roger" <Ro...@atosorigin.com>.
> 
> Besides, HashMap is not thread-safe, have you tried it with a
> thread-safe implementaion (i.e. Map m =
> Collections.synchronizedMap(new HashMap(...));)
> 

Yep, that fixed it. Interestingly, the original servlet using the hashmap continues to work fine with Tomcat 4.1.31. I can only surmise that at one time, multiple accesses by the same client/session were serialised, either by Tomcat or by IIS. Anyone know? 

Thanks for everyomes help.

Regards
Roger

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted. 
_______________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Strange behaviour after upgrade to 5.5.20

Posted by Gregor Schneider <rc...@googlemail.com>.
Hi Roger,

just a shot from the hip:

Maybe you want to overwrite the method public int hashcode() for the
objects being put into the hashmap - you should not rely on the
default implementation of java.lang.Object.hashcode().

Besides, HashMap is not thread-safe, have you tried it with a
thread-safe implementaion (i.e. Map m =
Collections.synchronizedMap(new HashMap(...));)

HTH

Greg
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Strange behaviour after upgrade to 5.5.20

Posted by "Varley, Roger" <Ro...@atosorigin.com>.
> I think you're going to have to be a bit less vague if you 
> want any real
> responses.  A description of the actual symptoms, exact error 
> messages,
> log entries, etc., would help.  "Strange behaviour" doesn't 
> give anyone
> much to go on.

Sorry, Im still grappling with the new Tomcat. There are no error messages and the servlet doesn't fail. However, the servlet puts state information into a hashmap that is stored in the session object. I am getting occassional strange behaviour that is consistant with the hashmap getting out of sync with the application. The same servlet works fine under Tomcat 4.1.31, which was I was wondering if/how session handling had changed dramatically. 

> 
> And yes, a lot changed between 4.1.31 and 5.5.20.  The 
> changelog is very
> detailed - and long.
> 

I know :) I've started wading through it, but I'm under time pressure to get the migration completed. I was hoping someone could short-circuit the effort and provide that "Ah-ha" moment.

Regards
Roger

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted. 
_______________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Strange behaviour after upgrade to 5.5.20

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Varley, Roger [mailto:Roger.Varley@atosorigin.com] 
> Subject: Strange behaviour after upgrade to 5.5.20
> 
> I'm just about there, but I've got a problem with a servlet
> that runs fine under the old setup but exhibits strange
> behaviour under the new setup.

I think you're going to have to be a bit less vague if you want any real
responses.  A description of the actual symptoms, exact error messages,
log entries, etc., would help.  "Strange behaviour" doesn't give anyone
much to go on.

And yes, a lot changed between 4.1.31 and 5.5.20.  The changelog is very
detailed - and long.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org