File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Singleton implemented using Servlets

 
jeff wisgo
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create only a single instance of a class which will run once Jakarta-Tomcat begins execution. To do this I have the following code:

*web.xml*


*InitializeController.java*


*Daemon.java*



When I run Jakarta-Tomcat, I can see the Daemon writing once every ~1 minute as expected. However, when I run other Servlets (which aren't related to this) there are additional instances of the Daemon which are apparently created, because I see many writes to the logfile, sometimes only 1 second apart. It seems like the init() function is being called again even though I t should not be.

Can anyone help out?

Thanks
[ October 01, 2004: Message edited by: jeff wisgo ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know what is causing your problem, but you might want to look into using context listeners to perform single-shot startup/shutdown actions rather than servlets.
 
jeff wisgo
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After doing some more research, it appears that the problem may be related to multiple class loaders, does anyone the semantics of how class loaders interact with Tomcat?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic