RE: Double loading when loading servlet on startup
Lot of thanks, Larry. You are absolutely right. It was due to different contexts. Thank you! I actually was in little panic about this problem:) --Che > -Original Message- > From: Larry Isaacs [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 08, 2001 10:05 PM > To: '[EMAIL PROTECTED]' > Subject: RE: Double loading when loading servlet on startup > > > I tried this scenario with Tomcat 3.2.1 and I only get one call > to init(). Are you on Windows? If your "ts" directory is actually > named "Ts", I think you would get two context's. What does your > tomcat log show about contexts being added? > > Larry > > > -Original Message- > > From: Alexander Cherinko [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 08, 2001 1:51 PM > > To: [EMAIL PROTECTED] > > Subject: RE: Double loading when loading servlet on startup > > > > > > The case: > > > > Nt/Linux v3.2.1,2,3. > > There is one context: > > > docBase="webapps/ts" > > crossContext="true" > > debug="1" > > reloadable="true"(or false) > > trusted="false" > > > > > > > The web.xml piece for this context > > > > Loader > > Loader > > 1 > > > > > > jdb shows double classes named Loader loaded with different > > instances of > > org.apache.tomcat.loader.AdaptiveClassLoader12 which have > > generation field 2 > > and 4 correspondingly. If I call > > > > Class.forName("MyClass") > > > > in init method of servlet and MyClass is subclass of thread I > > have double > > threads. And so on. > > gc gets nothing and trying to interrupt threads in servlet's > > destroy method > > gets nothing as well. > > > > And this occurs only when servlet is marked as > > load-on-startup. For ordinary > > servlet there is nothing like this. > > > > --Che > > > > > > > -Original Message- > > > From: Larry Isaacs [mailto:[EMAIL PROTECTED]] > > > Sent: Wednesday, August 08, 2001 7:58 PM > > > To: '[EMAIL PROTECTED]' > > > Subject: RE: Double loading when loading servlet on startup > > > > > > > > > In the past, the cases of "double loading" I've seen have all been > > > because an auto-loaded context (created by "AutoSetup" from the > > > webapps directory) was also manually loaded as a second > > context, i.e. > > > > > > > > docBase="webapps/examples" ... > > > > > > Each context gets its own instance of servlets. As a result, > > > init() is called twice, once for each context. > > > > > > There isn't enough information below to tell if this is the > > > source of the double-loading. > > > > > > Cheers, > > > Larry > > > > > > > -Original Message- > > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > > > Sent: Wednesday, August 08, 2001 12:32 PM > > > > To: [EMAIL PROTECTED] > > > > Subject: RE: Double loading when loading servlet on startup > > > > > > > > > > > > Got the same problem :(( (on v3.2.3 - NT) > > > > > > > > -Message d'origine- > > > > De : Alexander Cherinko [mailto:[EMAIL PROTECTED]] > > > > Envoye : mercredi 8 aout 2001 16:38 > > > > A : [EMAIL PROTECTED] > > > > Objet : Double loading when loading servlet on startup > > > > > > > > > > > > Hi > > > > problem is that when I mark servlets as load-on-startup they > > > > are loaded > > > > twice in jvm. > > > > I want this servlet to serve as initializer i.e. to > > > > initialize some other > > > > classes in its init method. > > > > The worst is that that classes are double loaded too. I.e. I > > > > want to init > > > > class which is Thread subclass to perform periodical > > custom action. As > > > > result I have double threads running in jvm and making the > > > > same things! That > > > > was obviousely not my real intention. > > > > From the other hand when I launch that initializer from > > > > common servlet (not > > > > loaded on startup) the problem is not present. > > > > The most strange thing about it is that in both cases all > > > > classes are loaded > > > > with the same ClassLoader. > > > > I cannot understand is it a bug or just I don't > > understand something. > > > > Please help. > > > > --Che > > > > > > > > > >
RE: Double loading when loading servlet on startup
I tried this scenario with Tomcat 3.2.1 and I only get one call to init(). Are you on Windows? If your "ts" directory is actually named "Ts", I think you would get two context's. What does your tomcat log show about contexts being added? Larry > -Original Message- > From: Alexander Cherinko [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 08, 2001 1:51 PM > To: [EMAIL PROTECTED] > Subject: RE: Double loading when loading servlet on startup > > > The case: > > Nt/Linux v3.2.1,2,3. > There is one context: > docBase="webapps/ts" > crossContext="true" > debug="1" > reloadable="true"(or false) > trusted="false" > > > > The web.xml piece for this context > > Loader > Loader > 1 > > > jdb shows double classes named Loader loaded with different > instances of > org.apache.tomcat.loader.AdaptiveClassLoader12 which have > generation field 2 > and 4 correspondingly. If I call > > Class.forName("MyClass") > > in init method of servlet and MyClass is subclass of thread I > have double > threads. And so on. > gc gets nothing and trying to interrupt threads in servlet's > destroy method > gets nothing as well. > > And this occurs only when servlet is marked as > load-on-startup. For ordinary > servlet there is nothing like this. > > --Che > > > > -Original Message- > > From: Larry Isaacs [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 08, 2001 7:58 PM > > To: '[EMAIL PROTECTED]' > > Subject: RE: Double loading when loading servlet on startup > > > > > > In the past, the cases of "double loading" I've seen have all been > > because an auto-loaded context (created by "AutoSetup" from the > > webapps directory) was also manually loaded as a second > context, i.e. > > > > > docBase="webapps/examples" ... > > > > Each context gets its own instance of servlets. As a result, > > init() is called twice, once for each context. > > > > There isn't enough information below to tell if this is the > > source of the double-loading. > > > > Cheers, > > Larry > > > > > -Original Message- > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > > Sent: Wednesday, August 08, 2001 12:32 PM > > > To: [EMAIL PROTECTED] > > > Subject: RE: Double loading when loading servlet on startup > > > > > > > > > Got the same problem :(( (on v3.2.3 - NT) > > > > > > -Message d'origine- > > > De : Alexander Cherinko [mailto:[EMAIL PROTECTED]] > > > Envoye : mercredi 8 aout 2001 16:38 > > > A : [EMAIL PROTECTED] > > > Objet : Double loading when loading servlet on startup > > > > > > > > > Hi > > > problem is that when I mark servlets as load-on-startup they > > > are loaded > > > twice in jvm. > > > I want this servlet to serve as initializer i.e. to > > > initialize some other > > > classes in its init method. > > > The worst is that that classes are double loaded too. I.e. I > > > want to init > > > class which is Thread subclass to perform periodical > custom action. As > > > result I have double threads running in jvm and making the > > > same things! That > > > was obviousely not my real intention. > > > From the other hand when I launch that initializer from > > > common servlet (not > > > loaded on startup) the problem is not present. > > > The most strange thing about it is that in both cases all > > > classes are loaded > > > with the same ClassLoader. > > > I cannot understand is it a bug or just I don't > understand something. > > > Please help. > > > --Che > > > > > >
RE: Double loading when loading servlet on startup
The case: Nt/Linux v3.2.1,2,3. There is one context: The web.xml piece for this context Loader Loader 1 jdb shows double classes named Loader loaded with different instances of org.apache.tomcat.loader.AdaptiveClassLoader12 which have generation field 2 and 4 correspondingly. If I call Class.forName("MyClass") in init method of servlet and MyClass is subclass of thread I have double threads. And so on. gc gets nothing and trying to interrupt threads in servlet's destroy method gets nothing as well. And this occurs only when servlet is marked as load-on-startup. For ordinary servlet there is nothing like this. --Che > -Original Message- > From: Larry Isaacs [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 08, 2001 7:58 PM > To: '[EMAIL PROTECTED]' > Subject: RE: Double loading when loading servlet on startup > > > In the past, the cases of "double loading" I've seen have all been > because an auto-loaded context (created by "AutoSetup" from the > webapps directory) was also manually loaded as a second context, i.e. > > docBase="webapps/examples" ... > > Each context gets its own instance of servlets. As a result, > init() is called twice, once for each context. > > There isn't enough information below to tell if this is the > source of the double-loading. > > Cheers, > Larry > > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 08, 2001 12:32 PM > > To: [EMAIL PROTECTED] > > Subject: RE: Double loading when loading servlet on startup > > > > > > Got the same problem :(( (on v3.2.3 - NT) > > > > -Message d'origine- > > De : Alexander Cherinko [mailto:[EMAIL PROTECTED]] > > Envoye : mercredi 8 aout 2001 16:38 > > A : [EMAIL PROTECTED] > > Objet : Double loading when loading servlet on startup > > > > > > Hi > > problem is that when I mark servlets as load-on-startup they > > are loaded > > twice in jvm. > > I want this servlet to serve as initializer i.e. to > > initialize some other > > classes in its init method. > > The worst is that that classes are double loaded too. I.e. I > > want to init > > class which is Thread subclass to perform periodical custom action. As > > result I have double threads running in jvm and making the > > same things! That > > was obviousely not my real intention. > > From the other hand when I launch that initializer from > > common servlet (not > > loaded on startup) the problem is not present. > > The most strange thing about it is that in both cases all > > classes are loaded > > with the same ClassLoader. > > I cannot understand is it a bug or just I don't understand something. > > Please help. > > --Che > > >
RE: Double loading when loading servlet on startup
3.2.1 on NT/Linux. I had the same problem on earlier versions. And Loic Lefevre [[EMAIL PROTECTED]] has got the same on NT with v.3.2.3. --Che > -Original Message- > From: Mike McGuinness [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 08, 2001 7:14 PM > To: [EMAIL PROTECTED] > Subject: Re: Double loading when loading servlet on startup > > > What version of tomcat? > > Alexander Cherinko wrote: > > > Hi > > problem is that when I mark servlets as load-on-startup they are loaded > > twice in jvm. > > I want this servlet to serve as initializer i.e. to initialize > some other > > classes in its init method. > > The worst is that that classes are double loaded too. I.e. I > want to init > > class which is Thread subclass to perform periodical custom action. As > > result I have double threads running in jvm and making the same > things! That > > was obviousely not my real intention. > > >From the other hand when I launch that initializer from common > servlet (not > > loaded on startup) the problem is not present. > > The most strange thing about it is that in both cases all > classes are loaded > > with the same ClassLoader. > > I cannot understand is it a bug or just I don't understand something. > > Please help. > > --Che > > >
RE: Double loading when loading servlet on startup
In the past, the cases of "double loading" I've seen have all been because an auto-loaded context (created by "AutoSetup" from the webapps directory) was also manually loaded as a second context, i.e. -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 08, 2001 12:32 PM > To: [EMAIL PROTECTED] > Subject: RE: Double loading when loading servlet on startup > > > Got the same problem :(( (on v3.2.3 - NT) > > -Message d'origine- > De : Alexander Cherinko [mailto:[EMAIL PROTECTED]] > Envoye : mercredi 8 aout 2001 16:38 > A : [EMAIL PROTECTED] > Objet : Double loading when loading servlet on startup > > > Hi > problem is that when I mark servlets as load-on-startup they > are loaded > twice in jvm. > I want this servlet to serve as initializer i.e. to > initialize some other > classes in its init method. > The worst is that that classes are double loaded too. I.e. I > want to init > class which is Thread subclass to perform periodical custom action. As > result I have double threads running in jvm and making the > same things! That > was obviousely not my real intention. > From the other hand when I launch that initializer from > common servlet (not > loaded on startup) the problem is not present. > The most strange thing about it is that in both cases all > classes are loaded > with the same ClassLoader. > I cannot understand is it a bug or just I don't understand something. > Please help. > --Che >
RE: Double loading when loading servlet on startup
Got the same problem :(( (on v3.2.3 - NT) -Message d'origine- De : Alexander Cherinko [mailto:[EMAIL PROTECTED]] Envoye : mercredi 8 aout 2001 16:38 A : [EMAIL PROTECTED] Objet : Double loading when loading servlet on startup Hi problem is that when I mark servlets as load-on-startup they are loaded twice in jvm. I want this servlet to serve as initializer i.e. to initialize some other classes in its init method. The worst is that that classes are double loaded too. I.e. I want to init class which is Thread subclass to perform periodical custom action. As result I have double threads running in jvm and making the same things! That was obviousely not my real intention. >From the other hand when I launch that initializer from common servlet (not loaded on startup) the problem is not present. The most strange thing about it is that in both cases all classes are loaded with the same ClassLoader. I cannot understand is it a bug or just I don't understand something. Please help. --Che
Re: Double loading when loading servlet on startup
What version of tomcat? Alexander Cherinko wrote: > Hi > problem is that when I mark servlets as load-on-startup they are loaded > twice in jvm. > I want this servlet to serve as initializer i.e. to initialize some other > classes in its init method. > The worst is that that classes are double loaded too. I.e. I want to init > class which is Thread subclass to perform periodical custom action. As > result I have double threads running in jvm and making the same things! That > was obviousely not my real intention. > >From the other hand when I launch that initializer from common servlet (not > loaded on startup) the problem is not present. > The most strange thing about it is that in both cases all classes are loaded > with the same ClassLoader. > I cannot understand is it a bug or just I don't understand something. > Please help. > --Che