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

Chip,

On 7/26/12 3:54 PM, Chip McVey wrote:
> I have read that Tomcat does not unload servlets (even though it 
> would be permissible to do so), but as you say, I have done some 
> logging in the destroy method, and I see this behavior.

Can you give us a stack trace of that event?

> A certain servlet within app B & C (let's call them B1 and C1) upon
>  init make a call to a servlet in app A (let's call it A1). What I 
> see is A1, B1, and C1 all initialize. The init is done by a thread 
> called " pool-2-thread-1", which seems like a system thread.  Ok no
>  problem.
> 
> Then, for some reason, A1's destroy method is called, and it is 
> called by a thread named " http-apr-8080-exec-3", making me think
> it is being called by a thread processing the request for either B1
> or C1, since no other requests from anyone outside of B or C have 
> happened yet.

http-apr-8080-exec-3 should be a request-processing thread, which has no
business calling destroy() on a servlet.

> After destroy winds down, then, A1's init method is called by a 
> thread named " http-apr-8080-exec-11" - another request processing
>  thread I assume.

Yes. This is probably happening because the servlet needs to be brought
(back) into service.

> Everything all works out in the end, and after that I don't see
> A1, B1, or C1 ever destroyed - but am I guaranteed that they won't
> ever be destroyed again unless TC is shutdown or they are manually 
> unloaded?

There are no guarantees, but Tomcat shouldn't randomly unloading your
servlets.

Do you only see one of these (surprising) unloads, or do they happen a
lot over time?

> I understand that given servlets can by spec go up & down, maybe 
> using them was not the right choice for an application that needs 
> permanency, but we're too late in development to make that switch 
> now.

Is your webapp somehow being damaged by these unload operations? A
servlet should be fairly lightweight, and the init method "should" run
very quickly.

> So I'm looking for a guarantee that no automatic destroys will 
> happen going forward just because Tomcat decides to do it on its 
> own.

You will never get that guarantee, because the servlet spec does not
require it.

> If it is instructed to shutdown/undeploy/unload by some outside 
> system or by a human user, that's fine, I'm not worried about
> that. But I don't want these servlets to be destroyed just because
> Tomcat decides to do so for whatever reason.

Sorry, you can't control that. What you can do is architect your
application in such a way that it doesn't matter.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlASqKAACgkQ9CaO5/Lv0PCcAQCfTz5FSmH+dangfTdWWu0urO2T
a+wAoMRX9W77BTrJMphN6OJUKTBsVVsL
=Si2b
-----END PGP SIGNATURE-----

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

Reply via email to