You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Noam Aigerman <no...@answers.com> on 2009/02/24 20:06:41 UTC

Problem with sessions on a fedora 10 machine

Hi,

I've been working with apache tomcat under windows for a few months now.
I've just setup a new fedora server, and deployed a .war file to it's
webapps directory.
Everything is running fine on the fedora machine, except that the
session doesn't seem to "stick".
doing something like the code below in my Servlet:

 

String check=session.getAttribute("check");

System.out.println("this is what I got: "+ check);

session.setAttribute("check","one");

 

And then going to that servlet's page and refreshing or navigating back
and forth form it create the following output in catalina.out:

 

this is what I got: null

this is what I got: null

this is what I got: null

this is what I got: null

 

checking the tomcat & catalina logs, there are no errors present...
web.xml has a timeout of 30...
Under MS it all works great...



Any thoughts?

 

Thanks, Noma


Re: Problem with sessions on a fedora 10 machine

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

Noam,

On 2/24/2009 5:22 PM, Noam Aigerman wrote:
> Hi Chris, 
> I managed to isolate the issue - you were close with your last guess
> :) - in proxy_ajp.conf I mapped my webapp by doing:
>
> ProxyPass / ajp://localhost:8009/Noam
>
> So whoever comes to my site can go to www.site.com and not
> www.site.com/Noam
>
> I am guessing the cookies are set to a wrong domain. What should I
> do? And is this kind of mapping the wrong way to do it in the first place?

So, your webapp thinks that the context path is "/Noam" instead of "/".
The cookie will be set to "host=www.site.com, path=/Noam". When your
browser sends further requests "to /", the cookie is not included
because the path doesn't match.

You can do one of two things:

1) Tell Tomcat to use an "empty session path" on your connector
   (see http://tomcat.apache.org/tomcat-5.5-doc/config/ajp.html
    or  http://tomcat.apache.org/tomcat-5.5-doc/config/http.html)

2) Deploy your application under the ROOT context instead (use ROOT.war
   or webapps/ROOT directory for deployment).

I favor #2 because then you won't forget that you have server-wide
configuration supporting a single webapp.

- -chris

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

iEYEARECAAYFAkmm2lsACgkQ9CaO5/Lv0PBATACcCMwYGrFrTH2gE+v5PopabGPV
CDcAoLUQG/uOi8jDJv3/EFQIoTCnrioh
=6PFj
-----END PGP SIGNATURE-----

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


RE: Problem with sessions on a fedora 10 machine

Posted by Noam Aigerman <no...@answers.com>.
Hi Chris, 
I managed to isolate the issue - you were close with your last guess :) - in proxy_ajp.conf I mapped my webapp by doing:
ProxyPass / ajp://localhost:8009/Noam
So whoever comes to my site can go to www.site.com and not www.site.com/Noam
I am guessing the cookies are set to a wrong domain. What should I do? And is this kind of mapping the wrong way to do it in the first place?
Thanks, Noam

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Wednesday, February 25, 2009 12:01 AM
To: Tomcat Users List
Subject: Re: Problem with sessions on a fedora 10 machine

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

Noam,

On 2/24/2009 2:06 PM, Noam Aigerman wrote:
> I've been working with apache tomcat under windows for a few months now.
> I've just setup a new fedora server, and deployed a .war file to it's
> webapps directory.
> Everything is running fine on the fedora machine, except that the
> session doesn't seem to "stick".
> doing something like the code below in my Servlet:
> 
> String check=session.getAttribute("check");
> System.out.println("this is what I got: "+ check);
> session.setAttribute("check","one");

How do you acquire the session object in the first place?

Are you using cookies or URL rewriting? Have you done an HTTP capture
using LiveHttpHeaders (or similar) or a TCP dump using Wireshark (or
similar)?

I wonder if the cookie is being set to a domain like www.foo.com but
your are using 'localhost' to access the webapp. This will cause your
browser to fail to send cookies back to the server on subsequent requests.

- -chris

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

iEYEARECAAYFAkmkbgUACgkQ9CaO5/Lv0PDXUwCfUVCeAWe7S4JlBlIYqGhx57kC
0XEAoLXpxrcTD5tNb4YpPXjVBZG5JaNa
=PGmv
-----END PGP SIGNATURE-----

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



Re: Problem with sessions on a fedora 10 machine

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

Noam,

On 2/24/2009 2:06 PM, Noam Aigerman wrote:
> I've been working with apache tomcat under windows for a few months now.
> I've just setup a new fedora server, and deployed a .war file to it's
> webapps directory.
> Everything is running fine on the fedora machine, except that the
> session doesn't seem to "stick".
> doing something like the code below in my Servlet:
> 
> String check=session.getAttribute("check");
> System.out.println("this is what I got: "+ check);
> session.setAttribute("check","one");

How do you acquire the session object in the first place?

Are you using cookies or URL rewriting? Have you done an HTTP capture
using LiveHttpHeaders (or similar) or a TCP dump using Wireshark (or
similar)?

I wonder if the cookie is being set to a domain like www.foo.com but
your are using 'localhost' to access the webapp. This will cause your
browser to fail to send cookies back to the server on subsequent requests.

- -chris

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

iEYEARECAAYFAkmkbgUACgkQ9CaO5/Lv0PDXUwCfUVCeAWe7S4JlBlIYqGhx57kC
0XEAoLXpxrcTD5tNb4YpPXjVBZG5JaNa
=PGmv
-----END PGP SIGNATURE-----

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