How to restrict multiple instances of a Servlet?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ravi_a
Posted On:   Wednesday, November 12, 2008 09:55 AM

I found an issue with Tomcat having multiple hosts defined. Please guide me if I was wrong. I have Tomcat 6.0.16 installed. In Server.xml, each of the Host names defined has different docBase. And in one of the Hosts have a servlet, MyScheduler, set to load on startup. To my surprise, when tomcat is started, MyScheduler was initiated that many number of times as the number of Hosts defined. This was unexpected. Is this issue found on other app servers? Please let me know if there is a solution for this issue. Can we have a single Host name and have multiple Aliases defined and a) each Host Alias has its own docBase as context? or b) each Context has multipl   More>>
			
I found an issue with Tomcat having multiple hosts defined.
Please guide me if I was wrong.

I have Tomcat 6.0.16 installed.

In Server.xml, each of the Host names defined has different docBase. And in one of the Hosts have a servlet, MyScheduler, set to load on startup.
To my surprise, when tomcat is started, MyScheduler was initiated that many number of times as the number of Hosts defined.

This was unexpected.
Is this issue found on other app servers?

Please let me know if there is a solution for this issue.

Can we have a single Host name and have multiple Aliases defined and
a) each Host Alias has its own docBase as context? or
b) each Context has multiple Host Alias names?

Please see below:
~~~~~~~~~~~~~~~~~~~~~~
What I have set in Server.xml is as follows:



unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
mydomain.com


directory="logs" prefix="myApp2_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>


unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
my.another.domain.com


directory="logs" prefix="myApp2_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>



What I was thinking, to behave like, was as follows:



unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">




directory="logs" prefix="mayApp1_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>





directory="logs" prefix="mayApp2_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>




~~~~~~~~~~~~~~~~~~~~~~
Thanks in advance
Ravi

   <<Less

Re: How to restrict multiple instances of a Servlet?

Posted By:   Robert_Lybarger  
Posted On:   Friday, November 14, 2008 09:20 AM

You might be wanting each [host ... ] element to have *different* appBase attribute values? (I'm not fully clear on Tomcat's behavior with docBase vs. appBase since I don't really use docBase, but I usually point appBase somewhere different when I need to.
About | Sitemap | Contact