you can have 2 instances if you have multiple <servlet> definitions in web.xml. you can calso have 2 instances if you have a <context> in your server.xml and it is autoreloading your context(or you have 2 <context> entries with the same docbase).
it sounds like the latter, where you have 2 instances of your context and they would be loaded in separate classloaders. Singletons are only unique to a classloader, so if you have it in /WEB-INF/lib(or classes), then it will be loaded again each time a copy of your context is loaded. You could move your singleton to /common/lib or adjust server.xml to load your context once. Charlie > -----Original Message----- > From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED] > Sent: Monday, March 24, 2003 9:02 PM > To: Tomcat Users List > Subject: Re: Servlet init() versus doPost() Classloading??? > > > > Rahul -- > > Yeah, you're right. The problem, though, is that he's seeing > two instances > start when a servlet's init() method is called. This means > the singleton > doesn't have the "mechanism to track the daemon state (running, > notStarted)" in place. > > We agree. My point was just that moving the code that calls into the > singleton from the init() method to the doPost() won't fix > anything. If > the singleton is broken, he'll have the same problem if he > hits the URL > twice. The problem lies in the singleton object. > > justin > > > At 05:27 PM 3/24/2003, you wrote: > >Hi Justin, > > > >Since the daemon is a singleton.... i think... hitting the > same URL twice > >shouldn't be a problem if mechanism to track the daemon > state (running, > >notStarted ) is in place. > > > >The problem as you said might be in the configuration. > > > >Cheers, > > > >Rahul > > > > > >----- Original Message ----- > >From: "Justin Ruthenbeck" <[EMAIL PROTECTED]> > >To: "Tomcat Users List" <[EMAIL PROTECTED]> > >Sent: Tuesday, March 25, 2003 12:43 PM > >Subject: Re: Servlet init() versus doPost() Classloading??? > > > > > > > Hi Micael, > > > > > > Seems you're sidestepping the real problem by trying to > initialize with a > > > doPost call ... the init() method is, afterall, meant for such > > > initialization. ;) Won't you have the same problem is > you hit the URL > > > twice? > > > > > > If there are two copies of your deamon thread starting, > then the problem > >is > > > in the code that starts them and can be changed to get the desired > > > behavior. Before going into thoughts on that, is there > anything non-basic > > > about your setup that would complicate the problem (such > as clustered > > > Tomcats, multiple JVMs, or other code that can start this daemon)? > > > > > > My apologies if you're absolutely sure you want to do this from a > > > doPost(). (?!) > > > > > > justin > > > ____________________________________ > Justin Ruthenbeck > Software Engineer, NextEngine Inc. > justinr - AT - nextengine DOT com > Confidential > See http://www.nextengine.com/confidentiality.php > ____________________________________ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]