You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mauroS <ro...@gmail.com> on 2009/11/10 22:44:29 UTC

HttpSessionListener sessionDestroyed only called once for sessionID

hello,

I run jbossweb-tomcat55.sar inside jboss-4.0.5.CR1

I have one EAR file with two WAR files inside.

I added HttpSessionListener in web.xml to both wars.

If I request both war files from the same browser I have two HttpSession
objects with different hash but with the same sessionID. That is exacly what
I expected.
but sessionDestroyed is only called for the first HttpSession object and
never for the second !
furthermore sessionDestroyed is never called again for this sessionID also
if new HttpSessions with new hash and same sessionID are created !
If I request the war file with the "not destroyed session object" again,
there is never a new session created.


thanks in advance 

-- 
View this message in context: http://old.nabble.com/HttpSessionListener-sessionDestroyed-only-called-once-for-sessionID-tp26291791p26291791.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: HttpSessionListener sessionDestroyed only called once for sessionID

Posted by mauroS <ro...@gmail.com>.

>"Request the war file"?  That sounds, well, a little imprecise, what 
>*exactly* are you requesting?
I request with a browser the doGet method of a servlet, inside the toGet I
call "request.getSession(true);"

>They're in different classloaders, (assuming you mean .hashCode()), so 
>that's expected.  This information is important, why?
I think a war file must have different classLoaders because one war should
never see objects from an other war, but I'm not an expert for this topic.
This information is important because I clear caches for the session object
and the destroy method is not called for all created sessions.

>How do you know this, what code are you using?
>What code is in your Listener?
se.getSession().hashCode() -> different hash 
se.getSession().getId() -> same ID


>But you said it's the same session id, so if it was destroyed once, why 
>would it be destroyed again?
because only the ID is the same, but multiple HttpSession objects are
created

>So you destroyed a session, and then made another request, and when you 
>did a new session was created.  Surprise? Not really.
NO, no new session is created -> the old not destroyed one is used !


-- 
View this message in context: http://old.nabble.com/HttpSessionListener-sessionDestroyed-only-called-once-for-sessionID-tp26291791p26292441.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: HttpSessionListener sessionDestroyed only called once for sessionID

Posted by Pid <pi...@pidster.com>.
On 10/11/2009 21:44, mauroS wrote:
>
> hello,
>
> I run jbossweb-tomcat55.sar inside jboss-4.0.5.CR1
>
> I have one EAR file with two WAR files inside.
>
> I added HttpSessionListener in web.xml to both wars.
>
> If I request both war files from the same browser

"Request the war file"?  That sounds, well, a little imprecise, what 
*exactly* are you requesting?

> I have two HttpSession objects with different hash but with the same sessionID.

They're in different classloaders, (assuming you mean .hashCode()), so 
that's expected.  This information is important, why?

How do you know this, what code are you using?
What code is in your Listener?


 > That is exacly what I expected.

I'd be surprised to see the same sessionId from both apps, if they are 
indeed separate apps.


> but sessionDestroyed is only called for the first HttpSession object and
> never for the second !

But you said it's the same session id, so if it was destroyed once, why 
would it be destroyed again?


> furthermore sessionDestroyed is never called again for this sessionID

Why would it be, if it was already destroyed?


> also if new HttpSessions with new hash and same sessionID are created !
> If I request the war file with the "not destroyed session object" again,
> there is never a new session created.

So you destroyed a session, and then made another request, and when you 
did a new session was created.  Surprise? Not really.


> thanks in advance
>

Err, right.


p



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


Re: HttpSessionListener sessionDestroyed only called once for sessionID

Posted by André Warnier <aw...@ice-sa.com>.
mauroS wrote:
> hello,
> 
> I run jbossweb-tomcat55.sar inside jboss-4.0.5.CR1
> 
> I have one EAR file with two WAR files inside.
> 
> I added HttpSessionListener in web.xml to both wars.
> 
> If I request both war files from the same browser I have two HttpSession
> objects with different hash but with the same sessionID. That is exacly what
> I expected.
> but sessionDestroyed is only called for the first HttpSession object and
> never for the second !
> furthermore sessionDestroyed is never called again for this sessionID also
> if new HttpSessions with new hash and same sessionID are created !
> If I request the war file with the "not destroyed session object" again,
> there is never a new session created.
> 
I don't know what the Java gurus here are going to say about that, but 
as far as I am concerned, it seems that you got exactly what you 
deserved. Is there a real use case for something like that in Java ?

Ignore this non-technical comment, it was from the heart, not the brain.
The world is full of wonders.

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


Re: HttpSessionListener sessionDestroyed only called once for sessionID

Posted by mauroS <ro...@gmail.com>.
>What do you mean "different hash"?
the hasCode of the java object

>So, the sessionDestroyed method is called, yet the session appears to
>continue to live and be accessible? Yikes

I have HttpSessionObj1 with ID 1 and hash A
           HttpSessionObj2 with ID 1 and hash B

A is destroyed B is never destroyed and is accessible .

-- 
View this message in context: http://old.nabble.com/HttpSessionListener-sessionDestroyed-only-called-once-for-sessionID-tp26291791p26292526.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: HttpSessionListener sessionDestroyed only called once for sessionID

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

Mauro,

On 11/10/2009 4:44 PM, mauroS wrote:
> I run jbossweb-tomcat55.sar inside jboss-4.0.5.CR1
> 
> I have one EAR file with two WAR files inside.
> 
> I added HttpSessionListener in web.xml to both wars.
> 
> If I request both war files from the same browser I have two HttpSession
> objects with different hash but with the same sessionID. That is exacly what
> I expected.

What do you mean "different hash"?

If you have a single session id, I would expect that you'd only one session.

> but sessionDestroyed is only called for the first HttpSession object and
> never for the second !

This is what I would expect if there is only one session. I don't know
how JBoss handles multiple WARs in EAR files (I'm not familiar with the
specs for EAR deployment), but it's possible that this is intended
behavior. Do you have documentation which suggests this is /not/ correct
behavior?

> furthermore sessionDestroyed is never called again for this sessionID also
> if new HttpSessions with new hash and same sessionID are created !

Again, what is this "hash" thing? Session ids shouldn't be re-used... at
least not for a very long time.

> If I request the war file with the "not destroyed session object" again,
> there is never a new session created.

So, the sessionDestroyed method is called, yet the session appears to
continue to live and be accessible? Yikes.

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

iEYEARECAAYFAkr54hUACgkQ9CaO5/Lv0PBWCwCeILogm+f3BMEbjvVGOVmGDTjU
fFAAoJe+RgjaomSw4eoJKSxDS62t/1Jl
=h1y1
-----END PGP SIGNATURE-----

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