You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tom Jones <tj...@acworld.com> on 2010/08/06 00:03:16 UTC

Tomcat Configuration Help

Hello,
I'm totally new to Tomcat and I have been searching the net for a little while now looking for info on configuring tomcat to host multiple apps on different ports and different web roots. I have come across some posts on running multiple instances which might be the right thing for me I'm still not sure.

So here is what I'm looking to configure, I just dont know if it's the right way.

tomcat
- webapps
-- appWebServices
-- appMainUserSite

I would like to run the app "appWebServices" on port 3100 with the docBase to be "tomcat/webapps/appWebServices". I would also like the app to support 500 simultaneous connections. Now I would like to run the app "appMainUserSite" on port 3200 with the docBase to be "tomcat/webapps/appMainUserSite". I would also like the app to support 100 simultaneous connections.

Now this configuration seems to work, but since I'm fairly new to this I thought I would get a second & third opinion. So is what I'm doing the right solution or is there a better one, like multiple instances etc.

Thanks,
tom

server.xml
<Server port="8005" shutdown="SHUTDOWN">
...
  <Service name="Catalina">
  ...
  </Service>
<!-- My Services Config -->
  <!-- Web Services -->
  <Service name="myWebService">
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="500" minSpareThreads="10"/>
    <Connector	executor="tomcatThreadPool" port="3100" redirectPort="3144" protocol="HTTP/1.1" connectionTimeout="300" 
				enableLookups="false" disableUploadTimeout="true" maxHttpHeaderSize="8192" URIEncoding="UTF-8" />
    <Engine name="myWebService" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false" 
      		xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="appWebServices"/>           
      </Host>
    </Engine>
  </Service>
  
  <!-- Main Site -->
  <Service name="mySite">
    <Executor name="mySiteThreadPool" namePrefix="catalina-exec-" maxThreads="100" minSpareThreads="10"/>
    <Connector executor="mySiteThreadPool" port="3200" protocol="HTTP/1.1" connectionTimeout="300" />
    <Engine name="mySite" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false" 
      		xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="appMainUserSite" />
      </Host>
    </Engine>
  </Service>	
</Server>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Configuration Help

Posted by Tom Jones <tj...@acworld.com>.
Chuck, thanks! I have been missing the obvious. I'm not sure how I've missed that for this long.

"ROOT is the required name for the default webapp for a <Host>."

I have it working per your suggestions and guidance, thanks a bunch.

Tom




----- Original Message -----
From: "Charles R Caldarale" <Ch...@unisys.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, August 5, 2010 4:21:02 PM
Subject: RE: Tomcat Configuration Help

> From: Tom Jones [mailto:tjones@acworld.com]
> Subject: Re: Tomcat Configuration Help
> 
> I put the <Context> element in so that I could set the
> docBase to my app directory thus avoiding the need to 
> append "appWebServices" to the URL. Is there a better 
> way to do this?

Yes - do what I said:

> > > tomcat
> > > - webapps
> > > -- appWebServices
> > > -- appMainUserSite
> > 
> > That's not good.  Each <Host> should have its own appBase; by sharing
> > them, you've made both apps available on both hosts.
> >
> > > <Context path="" docBase="appWebServices"/>
> > 
> > This is bad; do not put <Context> elements in server.xml.  Your webapp
> > should be located in this <Host>'s appBase directory, and named ROOT
> > (case-sensitive, even on Windows).  What you have now got you double
> > deployment, once as the default webapp and once more as appWebServices
> > - confusing at best.  The <Context> element, if you need one at all -
> > and you don't, in this situation - should be in the webapp's META-
> > INF/context.xml file, in other words:
> > 
> >     [appBase]/ROOT/META-INF/context.xml
> > 
> > and must not include path or docBase attributes.

ROOT is the required name for the default webapp for a <Host>.

  - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat Configuration Help

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tom Jones [mailto:tjones@acworld.com]
> Subject: Re: Tomcat Configuration Help
> 
> I put the <Context> element in so that I could set the
> docBase to my app directory thus avoiding the need to 
> append "appWebServices" to the URL. Is there a better 
> way to do this?

Yes - do what I said:

> > > tomcat
> > > - webapps
> > > -- appWebServices
> > > -- appMainUserSite
> > 
> > That's not good.  Each <Host> should have its own appBase; by sharing
> > them, you've made both apps available on both hosts.
> >
> > > <Context path="" docBase="appWebServices"/>
> > 
> > This is bad; do not put <Context> elements in server.xml.  Your webapp
> > should be located in this <Host>'s appBase directory, and named ROOT
> > (case-sensitive, even on Windows).  What you have now got you double
> > deployment, once as the default webapp and once more as appWebServices
> > - confusing at best.  The <Context> element, if you need one at all -
> > and you don't, in this situation - should be in the webapp's META-
> > INF/context.xml file, in other words:
> > 
> >     [appBase]/ROOT/META-INF/context.xml
> > 
> > and must not include path or docBase attributes.

ROOT is the required name for the default webapp for a <Host>.

  - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: Tomcat Configuration Help

Posted by Tom Jones <tj...@acworld.com>.
Chuck, this is great thanks. 

OK, I'll fill in some of the gaps here I'm running Tomcat 6.0.26, planning on upgrading to 6.0.29 shortly. Im using Java 6 on Mac OS X server. 

So I have one question, on your comments on <Context> elements in server.xml. I put the <Context> element in so that I could set the docBase to my app directory thus avoiding the need to append "appWebServices" to the URL (e.g. http://mysite:3100/ vs. http://mysite:3100/appWebServices). Is there a better way to do this?

Thanks,
tom



----- Original Message -----
From: "Charles R Caldarale" <Ch...@unisys.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Thursday, August 5, 2010 3:48:14 PM
Subject: RE: Tomcat Configuration Help

> From: Tom Jones [mailto:tjones@acworld.com]
> Subject: Tomcat Configuration Help
> 
> I'm totally new to Tomcat and I have been searching the net for a
> little while now looking for info on configuring tomcat to host
> multiple apps on different ports and different web roots.

Other than not telling us the Tomcat version you're using (along with the JVM and platform), you've done a pretty good job of explaining the situation.

If you don't need to isolate the applications by port (that's quite unusual), you can simplify things a bit by using virtual hosting:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts

> I have come across some posts on running multiple instances 
> which might be the right thing for me I'm still not sure.

Multiple instances are not strictly necessary, but might be easier to administer, and will obviously avoid undesired interaction between the two webapps.

> tomcat
> - webapps
> -- appWebServices
> -- appMainUserSite

That's not good.  Each <Host> should have its own appBase; by sharing them, you've made both apps available on both hosts.

> I would like to run the app "appWebServices" on port 3100 with the
> docBase to be "tomcat/webapps/appWebServices". I would also like the
> app to support 500 simultaneous connections. Now I would like to run
> the app "appMainUserSite" on port 3200 with the docBase to be
> "tomcat/webapps/appMainUserSite". I would also like the app to support
> 100 simultaneous connections.

As you surmised, you will need separate <Service> elements if you want to segregate the apps by port number.

> <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"

You might want to use a unique namePrefix for each <Executor> so you can more easily tell them apart in a thread dump (should that ever be necessary).

> <Connector executor="tomcatThreadPool" port="3100"
> redirectPort="3144"

If you don't have a <Connector> for port 3144, why do have a redirectPort?  Also be aware that many versions of IE don't handle HTTPS over anything other than port 443.

> <Host name="localhost" appBase="webapps" 

The appBase should be unique for each <Host>.

> <Context path="" docBase="appWebServices"/>

This is bad; do not put <Context> elements in server.xml.  Your webapp should be located in this <Host>'s appBase directory, and named ROOT (case-sensitive, even on Windows).  What you have now got you double deployment, once as the default webapp and once more as appWebServices - confusing at best.  The <Context> element, if you need one at all - and you don't, in this situation - should be in the webapp's META-INF/context.xml file, in other words:

    [appBase]/ROOT/META-INF/context.xml

and must not include path or docBase attributes.

> <Executor name="mySiteThreadPool" namePrefix="catalina-exec-"

See namePrefix comment above.

> <Host name="localhost" appBase="webapps"

See appBase comment above.

> <Context path="" docBase="appMainUserSite" />

See <Context> comment above.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Tomcat Configuration Help

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tom Jones [mailto:tjones@acworld.com]
> Subject: Tomcat Configuration Help
> 
> I'm totally new to Tomcat and I have been searching the net for a
> little while now looking for info on configuring tomcat to host
> multiple apps on different ports and different web roots.

Other than not telling us the Tomcat version you're using (along with the JVM and platform), you've done a pretty good job of explaining the situation.

If you don't need to isolate the applications by port (that's quite unusual), you can simplify things a bit by using virtual hosting:
http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
http://wiki.apache.org/tomcat/TomcatDevelopmentVirtualHosts

> I have come across some posts on running multiple instances 
> which might be the right thing for me I'm still not sure.

Multiple instances are not strictly necessary, but might be easier to administer, and will obviously avoid undesired interaction between the two webapps.

> tomcat
> - webapps
> -- appWebServices
> -- appMainUserSite

That's not good.  Each <Host> should have its own appBase; by sharing them, you've made both apps available on both hosts.

> I would like to run the app "appWebServices" on port 3100 with the
> docBase to be "tomcat/webapps/appWebServices". I would also like the
> app to support 500 simultaneous connections. Now I would like to run
> the app "appMainUserSite" on port 3200 with the docBase to be
> "tomcat/webapps/appMainUserSite". I would also like the app to support
> 100 simultaneous connections.

As you surmised, you will need separate <Service> elements if you want to segregate the apps by port number.

> <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"

You might want to use a unique namePrefix for each <Executor> so you can more easily tell them apart in a thread dump (should that ever be necessary).

> <Connector executor="tomcatThreadPool" port="3100"
> redirectPort="3144"

If you don't have a <Connector> for port 3144, why do have a redirectPort?  Also be aware that many versions of IE don't handle HTTPS over anything other than port 443.

> <Host name="localhost" appBase="webapps" 

The appBase should be unique for each <Host>.

> <Context path="" docBase="appWebServices"/>

This is bad; do not put <Context> elements in server.xml.  Your webapp should be located in this <Host>'s appBase directory, and named ROOT (case-sensitive, even on Windows).  What you have now got you double deployment, once as the default webapp and once more as appWebServices - confusing at best.  The <Context> element, if you need one at all - and you don't, in this situation - should be in the webapp's META-INF/context.xml file, in other words:

    [appBase]/ROOT/META-INF/context.xml

and must not include path or docBase attributes.

> <Executor name="mySiteThreadPool" namePrefix="catalina-exec-"

See namePrefix comment above.

> <Host name="localhost" appBase="webapps"

See appBase comment above.

> <Context path="" docBase="appMainUserSite" />

See <Context> comment above.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.