I answer me:

I'm using reloadable="true" in my context. Is that the reason a found this
behaviour??? Am I right??? If I use reloadable="false" init method of
servlets will not be executed, am I right???


Here is the explanation I found:
http://tomcat.apache.org/tomcat-3.2-doc/uguide/tomcat_ug.html

Context- reloadable: A reloadable flag. When developing a servlet it is
very convenient to have Tomcat reload it upon change, this lets you fix
bugs and have Tomcat test the new code without the need to shutdown and
restart. To turn on servlet reloading set the reloadable flag to true.
Detecting changes however is time consuming; moreover, since the new
servlets are getting loaded in a new class-loader object there are cases
where this class-reloading trigger casts errors. To avoid these problems
you can set the reloadable flag to false; this will disable the autoreload
feature.


Thanks

> Hi all,
>
> I have developed an application which instanciates a singleton class in
> the init method of a servlet. This servlet is defined in the web.xml with
> the <load-on-startup>1</load-on-startup> tag. This singleton class start a
> Thread which notifies the singleton class when a configuration file has
> changed. The thread checks if the file has changed periodically. If
> changed, it notifies the singleton.
>
> If I put this configuration file in a different directory than the one
> where the application is deployed, the application work as expected.
>
> If I put the configuration file in the WEB-INF/classes directory the
> thread notifies the singleton that the file has changed, that's OK. But
> what is my suprise that, the init method of the servlet is executed again
> by a thread named [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
> (viewing logs from log4j) because the instance is requested again. I
> thought it could be a tomcat behaviour. But the most strange is that the
> singleton class is built as if it was the first time the instance is
> requested... and in this singleton I used classes with static{} blocks and
> they are executed again.
>
> Does ContainerBackgroundProcessor allow us a mechanism to read
> configuration in class directory each time it is modified by reading it in
> the init method of servlets? How it works? How can happen this behaviour
> in which static blocks are newly executed and singleton classes newly
> built, is it a new execution of the JVM?
>
>
>
> Thanks,
>
>
> Juan Moratilla Peón
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>



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

Reply via email to