Multiple instances of servlets
Hi all, Is Tomcat supposed to create multiple instances of my servlet at startup? Or is it a bug? Background: I have two different domains connected to my Tomcat server (version 5.5.17): http://mydomain1.host.com and http://mydomain2.host.com "mydomain1" is directed to /home/web/tomcat/webapps/ROOT/ and "mydomain2" is directed to /home/web/tomcat/webapps/mydomain2/ Both domains use a copy of the same servlet except that they belong to different packages. Ex: The .java files under mydomain1 belong to package "com.mydomain1.bookingManager" and are located under /home/web/tomcat/webapps/ROOT/WEB-INF/classes/com/mydomain1/bookingManager/ The .java files under mydomain2 belong to package "com.mydomain2.bookingManager" and are located under /home/web/tomcat/webapps/mydomain2/WEB-INF/classes/com/mydomain2/bookingManager/ Problem: == When Tomcat starts it creates only ONE instance of the "mydomain1" -servlet, and FOUR instances of the "mydomain2" servlet. I would really like to only have ONE instance of each servlet. How can I achieve this? I have searched Google for answers but only found contradicting statements. Some say that Tomcat creates one, and only one instance of each servlet. Other say the opposite. All help is appreciated! Thanks in advance BR/Magnus - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple instances of servlets
How many web.xml files do you have, and how many declarations are there in those files? Each one of those is a different servlet (even if some of them happen to be implemented by similar Java classes). Normally, Tomcat will create one instance of each of those servlets (or one per JVM in a distributed application). Things are different if you use the single-thread model, but that's not recommended. See the servlet spec for the official details. -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: Hi all, Is Tomcat supposed to create multiple instances of my servlet at startup? Or is it a bug? Background: I have two different domains connected to my Tomcat server (version 5.5.17): http://mydomain1.host.com and http://mydomain2.host.com "mydomain1" is directed to /home/web/tomcat/webapps/ROOT/ and "mydomain2" is directed to /home/web/tomcat/webapps/mydomain2/ Both domains use a copy of the same servlet except that they belong to different packages. Ex: The .java files under mydomain1 belong to package "com.mydomain1.bookingManager" and are located under /home/web/tomcat/webapps/ROOT/WEB-INF/classes/com/mydomain1/bookingManager/ The .java files under mydomain2 belong to package "com.mydomain2.bookingManager" and are located under /home/web/tomcat/webapps/mydomain2/WEB-INF/classes/com/mydomain2/bookingManager/ Problem: == When Tomcat starts it creates only ONE instance of the "mydomain1" -servlet, and FOUR instances of the "mydomain2" servlet. I would really like to only have ONE instance of each servlet. How can I achieve this? I have searched Google for answers but only found contradicting statements. Some say that Tomcat creates one, and only one instance of each servlet. Other say the opposite. All help is appreciated! Thanks in advance BR/Magnus - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple instances of servlets
Hi Len! This is how my two web.xml files look like: /home/web/tomcat/webapps/ROOT/WEB-INF/web.xml com.mydomain1.bookingManager.BookingManager com.mydomain1.bookingManager.BookingManager 1 com.mydomain1.bookingManager.BookingManager /servlet/com.mydomain1.bookingManager.BookingManager --> com.mydomain1.log.Log com.mydomain1.log.Log com.mydomain1.log.Log /servlet/com.mydomain1.log.Log --> com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain /servlet/com.mydomain1.poll.PollMain --> com.mydomain1.discgolf.bookingManager.BookingManager com.mydomain1.discgolf.bookingManager.BookingManager 2 com.mydomain1.discgolf.bookingManager.BookingManager /servlet/com.mydomain1.discgolf.bookingManager.BookingManager --> com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain /servlet/com.mydomain1.discgolf.poll.PollMain /home/web/tomcat/webapps/mydomain2/WEB-INF/web.xml com.mydomain2.bookingManager.BookingManager com.mydomain2.bookingManager.BookingManager 1 com.mydomain2.bookingManager.BookingManager /servlet/com.mydomain2.bookingManager.BookingManager As I mentioned earlier it is mydomain2 that get four instances of the "BookingManager" servlet. Comments? Thanks /Magnus - Original Message - From: "Len Popp" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Wednesday, June 14, 2006 4:44 PM Subject: Re: Multiple instances of servlets How many web.xml files do you have, and how many declarations are there in those files? Each one of those is a different servlet (even if some of them happen to be implemented by similar Java classes). Normally, Tomcat will create one instance of each of those servlets (or one per JVM in a distributed application). Things are different if you use the single-thread model, but that's not recommended. See the servlet spec for the official details. -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: Hi all, Is Tomcat supposed to create multiple instances of my servlet at startup? Or is it a bug? Background: I have two different domains connected to my Tomcat server (version 5.5.17): http://mydomain1.host.com and http://mydomain2.host.com "mydomain1" is directed to /home/web/tomcat/webapps/ROOT/ and "mydomain2" is directed to /home/web/tomcat/webapps/mydomain2/ Both domains use a copy of the same servlet except that they belong to different packages. Ex: The .java files under mydomain1 belong to package "com.mydomain1.bookingManager" and are located under /home/web/tomcat/webapps/ROOT/WEB-INF/classes/com/mydomain1/bookingManager/ The .java files under mydomain2 belong to package "com.mydomain2.bookingManager" and are located under /home/web/tomcat/webapps/mydomain2/WEB-INF/classes/com/mydomain2/bookingManager/ Problem: == When Tomcat starts it creates only ONE instance of the "mydomain1" -servlet, and FOUR instances of the "mydomain2" servlet. I would really like to only have ONE instance of each servlet. How can I achieve this? I have searched Google for answers but only found contradicting statements. Some say that Tomcat creates one, and only one instance of each servlet. Other say the opposite. All help is appreciated! Thanks in advance BR/Magnus - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple instances of servlets
When starting a new thread (ie sending a message to the list about a new topic) please do not reply to an existing message and change the subject line. To many of the list archiving services and mail clients used by list subscribers this makes your new message appear as part of the old thread. This makes it harder for other users to find relevant information when searching the lists. This is known as thread hijacking and is behaviour that is frowned upon on this list. Frequent offenders will be removed from the list. It should also be noted that many list subscribers automatically ignore any messages that hijack another thread. The correct procedure is to create a new message with a new subject. This will start a new thread. Mark tomcat-user-owner - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple instances of servlets
I don't see anything there that would cause the servlet in mydomain2 to be loaded 4 times. The only thing I can think of is that the servlet might be running in single-thread mode (by implementing the SingleThreadModel interface). -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: Hi Len! This is how my two web.xml files look like: /home/web/tomcat/webapps/ROOT/WEB-INF/web.xml com.mydomain1.bookingManager.BookingManager com.mydomain1.bookingManager.BookingManager 1 com.mydomain1.bookingManager.BookingManager /servlet/com.mydomain1.bookingManager.BookingManager --> com.mydomain1.log.Log com.mydomain1.log.Log com.mydomain1.log.Log /servlet/com.mydomain1.log.Log --> com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain /servlet/com.mydomain1.poll.PollMain --> com.mydomain1.discgolf.bookingManager.BookingManager com.mydomain1.discgolf.bookingManager.BookingManager 2 com.mydomain1.discgolf.bookingManager.BookingManager /servlet/com.mydomain1.discgolf.bookingManager.BookingManager --> com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain /servlet/com.mydomain1.discgolf.poll.PollMain /home/web/tomcat/webapps/mydomain2/WEB-INF/web.xml com.mydomain2.bookingManager.BookingManager com.mydomain2.bookingManager.BookingManager 1 com.mydomain2.bookingManager.BookingManager /servlet/com.mydomain2.bookingManager.BookingManager As I mentioned earlier it is mydomain2 that get four instances of the "BookingManager" servlet. Comments? Thanks /Magnus - Original Message - From: "Len Popp" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Wednesday, June 14, 2006 4:44 PM Subject: Re: Multiple instances of servlets How many web.xml files do you have, and how many declarations are there in those files? Each one of those is a different servlet (even if some of them happen to be implemented by similar Java classes). Normally, Tomcat will create one instance of each of those servlets (or one per JVM in a distributed application). Things are different if you use the single-thread model, but that's not recommended. See the servlet spec for the official details. -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: > Hi all, > > Is Tomcat supposed to create multiple instances of my servlet at startup? > Or > is it a bug? > > Background: > > I have two different domains connected to my Tomcat server (version > 5.5.17): > http://mydomain1.host.com and > http://mydomain2.host.com > > "mydomain1" is directed to /home/web/tomcat/webapps/ROOT/ > and "mydomain2" is directed to /home/web/tomcat/webapps/mydomain2/ > > Both domains use a copy of the same servlet except that they belong to > different packages. Ex: > The .java files under mydomain1 belong to package > "com.mydomain1.bookingManager" and are located under > /home/web/tomcat/webapps/ROOT/WEB-INF/classes/com/mydomain1/bookingManager/ > > The .java files under mydomain2 belong to package > "com.mydomain2.bookingManager" and are located under > /home/web/tomcat/webapps/mydomain2/WEB-INF/classes/com/mydomain2/bookingManager/ > > Problem: > == > When Tomcat starts it creates only ONE instance of the > "mydomain1" -servlet, > and FOUR instances of the "mydomain2" servlet. > I would really like to only have ONE instance of each servlet. How can I > achieve this? > > I have searched Google for answers but only found contradicting > statements. > Some say that Tomcat creates one, and only one instance of each servlet. > Other say the opposite. > > > All help is appreciated! > > Thanks in advance > BR/Magnus > > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple instances of servlets
Hi Len, The SingleThreadModel Interface is _not_ used in the servlet. Maybe I should write a bugreport? Thanks for your help! BR/Magnus - Original Message - From: "Len Popp" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Friday, June 16, 2006 6:30 PM Subject: Re: Multiple instances of servlets I don't see anything there that would cause the servlet in mydomain2 to be loaded 4 times. The only thing I can think of is that the servlet might be running in single-thread mode (by implementing the SingleThreadModel interface). -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: Hi Len! This is how my two web.xml files look like: /home/web/tomcat/webapps/ROOT/WEB-INF/web.xml com.mydomain1.bookingManager.BookingManager com.mydomain1.bookingManager.BookingManager 1 com.mydomain1.bookingManager.BookingManager /servlet/com.mydomain1.bookingManager.BookingManager --> com.mydomain1.log.Log com.mydomain1.log.Log com.mydomain1.log.Log /servlet/com.mydomain1.log.Log --> com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain com.mydomain1.poll.PollMain /servlet/com.mydomain1.poll.PollMain --> com.mydomain1.discgolf.bookingManager.BookingManager com.mydomain1.discgolf.bookingManager.BookingManager 2 com.mydomain1.discgolf.bookingManager.BookingManager /servlet/com.mydomain1.discgolf.bookingManager.BookingManager --> com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain com.mydomain1.discgolf.poll.PollMain /servlet/com.mydomain1.discgolf.poll.PollMain /home/web/tomcat/webapps/mydomain2/WEB-INF/web.xml com.mydomain2.bookingManager.BookingManager com.mydomain2.bookingManager.BookingManager 1 com.mydomain2.bookingManager.BookingManager /servlet/com.mydomain2.bookingManager.BookingManager As I mentioned earlier it is mydomain2 that get four instances of the "BookingManager" servlet. Comments? Thanks /Magnus - Original Message - From: "Len Popp" <[EMAIL PROTECTED]> To: "Tomcat Users List" Sent: Wednesday, June 14, 2006 4:44 PM Subject: Re: Multiple instances of servlets How many web.xml files do you have, and how many declarations are there in those files? Each one of those is a different servlet (even if some of them happen to be implemented by similar Java classes). Normally, Tomcat will create one instance of each of those servlets (or one per JVM in a distributed application). Things are different if you use the single-thread model, but that's not recommended. See the servlet spec for the official details. -- Len On 6/14/06, Magnus Larsgården <[EMAIL PROTECTED]> wrote: > Hi all, > > Is Tomcat supposed to create multiple instances of my servlet at > startup? > Or > is it a bug? > > Background: > > I have two different domains connected to my Tomcat server (version > 5.5.17): > http://mydomain1.host.com and > http://mydomain2.host.com > > "mydomain1" is directed to /home/web/tomcat/webapps/ROOT/ > and "mydomain2" is directed to /home/web/tomcat/webapps/mydomain2/ > > Both domains use a copy of the same servlet except that they belong to > different packages. Ex: > The .java files under mydomain1 belong to package > "com.mydomain1.bookingManager" and are located under > /home/web/tomcat/webapps/ROOT/WEB-INF/classes/com/mydomain1/bookingManager/ > > The .java files under mydomain2 belong to package > "com.mydomain2.bookingManager" and are located under > /home/web/tomcat/webapps/mydomain2/WEB-INF/classes/com/mydomain2/bookingManager/ > > Problem: > == > When Tomcat starts it creates only ONE instance of the > "mydomain1" -servlet, > and FOUR instances of the "mydomain2" servlet. > I would really like to only have ONE instance of each servlet. How can I > achieve this? > > I have searched Google for answers but only found contradicting > statements. > Some say that Tomcat creates one, and only one instance of each servlet. > Other say the opposite. > > > All help is appreciated! > > Thanks in advance > BR/Magnus > > > > > > > > - > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To start a new topic, e-mail: user