Hi.
As part of the "beginners" rubrique, I have a question which will
undoubtedly show the depth of my lack of knowledge of things Java and
Tomcat. But maybe there will be a sympathetic soul here.
Since I am still missing much of the underlying knowledge, I would beg
that whoever answers does not get too "classy" on me. The question is
at the level of generalities, not classloaders or GC strategies level.
My question concerns the "starting" and "stopping" of web applications
under Tomcat, and what these terms really mean in that context.
If I look at the Tomcat Manager application, and its capabilities of
starting ans stopping applications, I get approximately the following
mental picture :
- we have a JVM. That is the real process that is running, at the OS
level. That process can be killed, or decide to stop running, at which
point we don't have a JVM process anymore, and thus no Tomcat and no
webapps at all. That's kind of drastic and definitive.
- "inside" the JVM, we have a Tomcat. Basically, that is only code
which the JVM is "running" (a bit like a Perl interpreter process runs
the list of Perl opcodes it has compiled a perl script into). Tomcat
can somehow decide that it is tired of living, and tell the JVM to stop
running it. At which point we have no webapps and no Tomcat anymore,
and consequently (I presume, but this is already a bit less clear), no
JVM anymore either, because not having anything to do anymore, it would
also exit. Or ?
- then inside Tomcat, we have webapps. It's already getting more
mysterious there for me, but I resolve this intellectually by imagining
that a webapp is just a "subroutine" which Tomcat runs from time to
time, in response to a HTTP request for example. So a webapp in fact
"is" Tomcat, in the sense that when it runs it does so as an integral
part of the Tomcat process. So much so that if a webapp were to execute
a "system.exit()", it would take the whole Tomcat (and JVM) with it. Yes ?
So now, when the Tomcat Manager application decides to "stop a web
application", what it really does is just to prevent any further calls
to this web application in the future, by removing some entry in a table
of "runnable webapps". In other words, it does not really "stop" or
"kill" any currently running instance of that webapp (those are allowed
to finish what they are doing and "return()" to Tomcat main code), but
it makes it so that any further call to "/mywebapp" will be met by a
"what ?" response.
Is this a correct interpretation ?
Now comes the basic question : can a webapp stop itself, without taking
the whole Tomcat and JVM with it ? In other words, in response to
something (a variable being a certain value, or the interception of some
event or whatever), can my webapp decide to stop doing what it is
currently doing, clean up after itself, and then do something to prevent
itself ever being called again in the future of this Tomcat instance ?
(or say at least until some external intervention activates it again).
My next question in this rubrique will be about what individual webapps
really "share" at the deep-down level, considering that they are all in
the end issued from the same JVM process.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]