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

Reply via email to