You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alex79 <as...@gmail.com> on 2007/10/08 00:59:28 UTC
Problem with session
Hi,
I am running a web service on tomcat, which I am not very familiar with
(tomcat).
A client application that sends requests to this web service sends the
session id with a certain type of request. After many requests (over 1000)
occurring in the same session (in other words, by the same client), the
session id no longer exists (the web service throws an error when the type
of request that has the session id parameter gives an unknown session id).
The session cannot have timed out as the time out is set to 120 minutes in
web.xml and anyway the 1000 requests occurs in about 1 minute. Any idea if
tomcat is somehow auto-refreshing my web application (or itself) causing my
session to be cleared?
Thank you for pointing me out to any useful info.
Alex
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13088302
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alex,
Alex79 wrote:
> You mentionned a session listener, can you point me out to a tutorial on how
> to do it?
Easy: write a class that implements
javax.servlet.http.HttpSesionListener and then enable it in your web.xml
file like this:
<listener>
<listener-class>package.for.your.Class</listener-class>
</listener>
<listener>s are defined after <filter>s in your web.xml file.
> Are there any generic session listener that I could use out of the
> box?
Not really, but they're really easy to write: just implement two
methods. You're really only interested in the "destroyed" method:
public void sessionDestroyed(HttpSessionEvent se)
{
Session s = se.getSession();
logger.debug("Session " + s.getSessionId() + " is being destroyed",
new Throwable());
}
This will log a stack trace whenever a session is destroyed. You should
be able to see what component is calling session.invalidate originally.
Hopefully, you are using a logger that will make a nice stack trace for
you. Otherwise, you can use a StringWriter or something along with
Throwable.printStackTrace().
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHC5709CaO5/Lv0PARAlc8AKDCBdqVq5zh8HMniESsISLz2Dx3bgCfQ+vK
EF1H7zOFKcDtU6FtfqPbnxc=
=KTvb
-----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: Problem with session
Posted by Alex79 <as...@gmail.com>.
Hi,
I finally found out what the problem was. There is nothing stored in the
session (I tried the SessionListener from tomcat 5.5.25 in my tomcat
version, it worked - I saw contextInitialized entries in the standard
context log) but I never saw any sessioncreated - nor destroyed - event. By
checking the source code I saw that the session (or cache) is represented as
a LinkedHashMap with an overriden removeEldestEntry method that returns true
to remove eldest entry when the size > 1000. The problem was in the client
app where some type of request would generate a new random session id at
each request. So after sending 1000+ of this type of request, the cache had
lost any other info on previous active sessions. I did not know that one of
the request would generate a new id each time...
Thanks for your help, now at least I am a bit less newbie with tomcat ;)
Caldarale, Charles R wrote:
>
>> From: Alex79 [mailto:asoares1@gmail.com]
>> Subject: RE: Problem with session
>>
>> You mentionned a session listener, can you point me out to a
>> tutorial on how to do it?
>
> See section 10 of the Servlet spec.
>
>> Are there any generic session listener that I could use out
>> of the box?
>
> There's one in the 5.5.25 distribution:
>
> webapps/servlets-examples/WEB-INF/classes/listeners/SessionListener.java
> (I don't have 5.0 around anymore, but I would expect it to be in there
> as well.)
>
> Look in:
> webapps/servlets-examples/WEB-INF/web.xml
> to see how to configure it.
>
> - 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
>
>
>
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13139330
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Alex79 [mailto:asoares1@gmail.com]
> Subject: RE: Problem with session
>
> You mentionned a session listener, can you point me out to a
> tutorial on how to do it?
See section 10 of the Servlet spec.
> Are there any generic session listener that I could use out
> of the box?
There's one in the 5.5.25 distribution:
webapps/servlets-examples/WEB-INF/classes/listeners/SessionListener.java
(I don't have 5.0 around anymore, but I would expect it to be in there
as well.)
Look in:
webapps/servlets-examples/WEB-INF/web.xml
to see how to configure it.
- 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
RE: Problem with session
Posted by Alex79 <as...@gmail.com>.
Hi Chuck,
I tried it out with a maxKeepAliveRequests="-1" in my main connector (the
one on port 8080) without any success. I also verified that there is no call
to an invalidate() method (only invalidateObject() but not on the session).
You mentionned a session listener, can you point me out to a tutorial on how
to do it? Are there any generic session listener that I could use out of the
box?
If you have any other idea, please let me know. Thanks again.
Alex
Alex79 wrote:
>
> Thanks Chuck, I'll check out for a call to the invalidate method of the
> session. I'll also give a try to the maxKeepAliveRequests, sounds like a
> good call to me. I read about it in the doc, it says that if there are
> more than 100 (default value as you mentionned) unprocessed queries in the
> pipeline, the server closes the connection. Is this for one client or for
> the whole server? What impact does it have on one session?
>
> Here's all the version info:
> Tomcat Version | JVM Version | JVM Vendor | OS Name | OS Version | OS
> Architecture
> Apache Tomcat/5.0.25 | 1.6.0_01-b06 | Sun Microsystems Inc. | Windows XP |
> 5.1 | x86
>
> I saw some info on max thread also, could it be the cause? One thing I
> said in my first post that I did not exagerate, the server does receive a
> LOT of requests per second.
>
> Than you again.
>
>
> Caldarale, Charles R wrote:
>>
>>> From: Alex79 [mailto:asoares1@gmail.com]
>>> Subject: RE: Problem with session
>>>
>>> Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
>>
>> That's a couple of updates old, but very unlikely to be an issue.
>>
>>> When the problem occurs, I see a WARN level message that
>>> says that there is no header (custom info stored by the
>>> webapp) in session (managed by tomcat I guess)
>>
>> Yes, that does sound like a Tomcat-managed session. Is there any chance
>> your webapp is calling the invalidate() method for the session?
>>
>> You could always define a session listener for your webapp and have it
>> log the comings and goings of each session.
>>
>>> Where can I find the exact tomcat version?
>>
>> It's usually part of the name of the installation directory. It can be
>> found by running the version.bat script, or looking on Tomcat's status
>> page (http://<host>:<port>/manager/status).
>>
>> - 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
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13117059
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by Alex79 <as...@gmail.com>.
Thanks Chuck, I'll check out for a call to the invalidate method of the
session. I'll also give a try to the maxKeepAliveRequests, sounds like a
good call to me. I read about it in the doc, it says that if there are more
than 100 (default value as you mentionned) unprocessed queries in the
pipeline, the server closes the connection. Is this for one client or for
the whole server? What impact does it have on one session?
Here's all the version info:
Tomcat Version | JVM Version | JVM Vendor | OS Name | OS Version | OS
Architecture
Apache Tomcat/5.0.25 | 1.6.0_01-b06 | Sun Microsystems Inc. | Windows XP |
5.1 | x86
I saw some info on max thread also, could it be the cause? One thing I said
in my first post that I did not exagerate, the server does receive a LOT of
requests per second.
Than you again.
Caldarale, Charles R wrote:
>
>> From: Alex79 [mailto:asoares1@gmail.com]
>> Subject: RE: Problem with session
>>
>> Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
>
> That's a couple of updates old, but very unlikely to be an issue.
>
>> When the problem occurs, I see a WARN level message that
>> says that there is no header (custom info stored by the
>> webapp) in session (managed by tomcat I guess)
>
> Yes, that does sound like a Tomcat-managed session. Is there any chance
> your webapp is calling the invalidate() method for the session?
>
> You could always define a session listener for your webapp and have it
> log the comings and goings of each session.
>
>> Where can I find the exact tomcat version?
>
> It's usually part of the name of the installation directory. It can be
> found by running the version.bat script, or looking on Tomcat's status
> page (http://<host>:<port>/manager/status).
>
> - 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
>
>
>
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13105465
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Alex79 [mailto:asoares1@gmail.com]
> Subject: RE: Problem with session
>
> Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
That's a couple of updates old, but very unlikely to be an issue.
> When the problem occurs, I see a WARN level message that
> says that there is no header (custom info stored by the
> webapp) in session (managed by tomcat I guess)
Yes, that does sound like a Tomcat-managed session. Is there any chance
your webapp is calling the invalidate() method for the session?
You could always define a session listener for your webapp and have it
log the comings and goings of each session.
> Where can I find the exact tomcat version?
It's usually part of the name of the installation directory. It can be
found by running the version.bat script, or looking on Tomcat's status
page (http://<host>:<port>/manager/status).
- 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
RE: Problem with session
Posted by Alex79 <as...@gmail.com>.
Java version:
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode)
I modified the log4j.properties file to receive all logs from INFO. When the
problem occurs, I see a WARN level message that says that there is no header
(custom info stored by the webapp) in session (managed by tomcat I guess)
for session id XXXX and that this is a normal condition after a server
reboot and that it will occur until the client refreshes (that is, until the
client send another type of request that initializes the header in the
session). This message comes from the webapp (I have the source code and saw
the message in it). That's why it makes me think that it has something to do
with tomcat (or the webapp) restarting alone for some reason. I'll try to
look further in the source code and try to see if the sessionid comes from
tomcat, maybe I got that wrong and that it does come from tomcat.
Where can I find the exact tomcat version?
Thank you,
Caldarale, Charles R wrote:
>
>> From: Alex79 [mailto:asoares1@gmail.com]
>> Subject: RE: Problem with session
>>
>> I checked the log in the logs directory, there's nothing that
>> says tomcat has been restarted.
>
> What about the webapp being restarted? (Not likely either.)
>
>> I run tomcat 5.0.
>
> Tomcat 5.0.what?
>
>> It's an internal session id that is stored in the session.
>
> So this is not a Tomcat issue - it's a problem with your webapp.
>
>> The JRE says version 6 in the readme.
>
> You need to be more precise; run java -version to get the exact level.
>
>> I'm going to have a look at the keepalive and let you know if
>> it has an impact.
>
> Since this appears to be an application-specific session identifier, and
> not the one defined by the servlet spec, the keepalive setting shouldn't
> matter.
>
> - 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
>
>
>
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13101555
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Alex79 [mailto:asoares1@gmail.com]
> Subject: RE: Problem with session
>
> I checked the log in the logs directory, there's nothing that
> says tomcat has been restarted.
What about the webapp being restarted? (Not likely either.)
> I run tomcat 5.0.
Tomcat 5.0.what?
> It's an internal session id that is stored in the session.
So this is not a Tomcat issue - it's a problem with your webapp.
> The JRE says version 6 in the readme.
You need to be more precise; run java -version to get the exact level.
> I'm going to have a look at the keepalive and let you know if
> it has an impact.
Since this appears to be an application-specific session identifier, and
not the one defined by the servlet spec, the keepalive setting shouldn't
matter.
- 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
RE: Problem with session
Posted by Alex79 <as...@gmail.com>.
Hi, thanks for the reply.
I checked the log in the logs directory, there's nothing that says tomcat
has been restarted.
I run tomcat 5.0.
It's an internal session id that is stored in the session.
I run on windows xp pro. The JRE says version 6 in the readme.
I'm going to have a look at the keepalive and let you know if it has an
impact.
Thank you very much for this info.
Caldarale, Charles R wrote:
>
>> From: Alex79 [mailto:asoares1@gmail.com]
>> Subject: Problem with session
>>
>> I am running a web service on tomcat, which I am not very
>> familiar with (tomcat).
>
> At least tell us the version of Tomcat you're using; also, although
> probably not relevant for this problem, include the JRE/JDK level and
> the platform you're running on.
>
>> A client application that sends requests to this web service
>> sends the session id with a certain type of request.
>
> Are you referring to a session cookie or the JSESSIONID parameter (as
> defined in the servlet spec), or is this a roll-your-own session
> identifier?
>
>> After many requests (over 1000) occurring in the same session
>> (in other words, by the same client), the session id no longer
>> exists (the web service throws an error when the type of request
>> that has the session id parameter gives an unknown session id).
>
> There is a maxKeepAliveRequests attribute for a <Connector> element,
> with a default setting of 100. It's possible that's coming into play,
> depending on the client you're using. Read about here:
> http://tomcat.apache.org/tomcat-5.5-doc/config/http.html
>
>> Any idea if tomcat is somehow auto-refreshing my web application
>> (or itself) causing my session to be cleared?
>
> Unlikely, but if the webapp is being restarted, it should show up in
> Tomcat's logs. Have you looked at them?
>
> - 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
>
>
>
--
View this message in context: http://www.nabble.com/Problem-with-session-tf4585082.html#a13100920
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: Problem with session
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Alex79 [mailto:asoares1@gmail.com]
> Subject: Problem with session
>
> I am running a web service on tomcat, which I am not very
> familiar with (tomcat).
At least tell us the version of Tomcat you're using; also, although
probably not relevant for this problem, include the JRE/JDK level and
the platform you're running on.
> A client application that sends requests to this web service
> sends the session id with a certain type of request.
Are you referring to a session cookie or the JSESSIONID parameter (as
defined in the servlet spec), or is this a roll-your-own session
identifier?
> After many requests (over 1000) occurring in the same session
> (in other words, by the same client), the session id no longer
> exists (the web service throws an error when the type of request
> that has the session id parameter gives an unknown session id).
There is a maxKeepAliveRequests attribute for a <Connector> element,
with a default setting of 100. It's possible that's coming into play,
depending on the client you're using. Read about here:
http://tomcat.apache.org/tomcat-5.5-doc/config/http.html
> Any idea if tomcat is somehow auto-refreshing my web application
> (or itself) causing my session to be cleared?
Unlikely, but if the webapp is being restarted, it should show up in
Tomcat's logs. Have you looked at them?
- 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