You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Conway Liu <cl...@xtra.co.nz> on 2011/02/03 08:10:54 UTC

Tomcat Service configuration for running sites

Hi,
 
Thanks to all who answered my previous post regarding running Tomcat with IIS7.
 
I am still quite confused about the whole thing, so I think I should try to 
forget about IIS for the time being, and concentrate first on how to get Tomcat 
service to serve a java website sitting physically outside of Tomcat's installed 
folder.
 
BTW, platform is Windows 2008 R2 64bit.
Tomcat installed is 5.5.32. (In my previous question I installed 6.0.30 but I 
now realised when the website was running on Linux, my manager was using 5.5.23 
and now I can only find 5.5.32 to download. I hope it makes no difference).
 
 
For example, Tomcat service is installed on: (... means some more sub folders or 
files within):
C:\Tomcat\
 
And the subfolders under this folder are:
C:\tomcat\bin\...   (contains tomcat5.exe, tomcat5w.exe, and 3 .jar files)
C:\tomcat\common\...
C:\tomcat\conf\...   (contains catalina.policy, catalina.properties, 
context.xml, logging.properties, server.xml, server-minimal.xml, 
tomcat-users.xml, web.xml)
C:\Tomcat\conf\Catalina\
C:\Tomcat\conf\Catalina\localhost
C:\tomcat\logs
C:\tomcat\server
C:\Tomcat\server\classes\
C:\Tomcat\server\lib\...   (many .jar files in there, e.g. catalina.jar)
C:\Tomcat\server\webapps\...
C:\tomcat\shared\...
C:\tomcat\temp
C:\tomcat\webapps\ROOT\...
C:\tomcat\work
 
My Java web application is placed in:
C:\WebApp1\
 
With subfolders:
C:\WebApp1\bin\...   (contains tomcat5.exe and tomcat5w.exe and many .sh and 
.bat files as we previously start this site using the startup.bat before I 
installed the Tomcat service)
C:\WebApp1\common\...
C:\WebApp1\conf\...   (contains catalina.policy, catalina.properties, 
context.xml, logging.properties, server.xml, server-minimal.xml, 
tomcat-users.xml, web.xml specifically used by this website)
C:\WebApp1\conf\Catalina\
C:\WebApp1\logs\
C:\WebApp1\server\
C:\WebApp1\server\lib\...   (many .jar files in there, e.g. catalina.jar)
C:\WebApp1\shared\...
C:\WebApp1\sslcerts\...   (SSL certificates in here)
C:\WebApp1\webapps\ROOT\...   (This is the root of the website. E.g. default.jsp 
sits in here)
C:\WebApp1\webapps\ROOT\WEB-INF\classes\...   (The java classes we created to be 
used for the website to interact with back-end database)
C:\WebApp1\webapps\ROOT\WEB-INF\lib\...   (some 3rd party .jar files 
specifically used by this website)
C:\WebApp1\webapps\ROOT\WEB-INF\web.xml   (contains the listener definition, 
points to the listener class, so that when this site starts the listener class 
can perform some initialisation tasks)
C:\WebApp1\work
 
 
Question:
1. How should I configure Tomcat service so that it serves the WebApp1 website? 
Which file in which folder to modify?
2. When Tomcat starts WebApp1 website, which set of configuration files is it 
using? (Those in C:\tomcat\conf\ or those in C:\WebApp1\conf\?)
3. If I am to add another website to the same server, say C:\WebApp2, with exact 
folder structure as WebApp1, how should I configure Tomcat service so that it 
serves both WebApp1 and WebApp2?
4. The two sites will use different IP addresses. For example WebApp1 is 
43.88.12.123, and WebApp2 is 43.88.12.133. How do I tell Tomcat which IP belongs 
to which website?
 
 
Again, your input is very much appreciated.
 
Best regards
Conway

RE: Tomcat Service configuration for running sites

Posted by Conway Liu <cl...@xtra.co.nz>.
Hi All,

I'm probably causing all the confusion here as I am quite confused about Tomcat myself so likely not explained my questions in a clear way. I apologise for that.

Anyway, I believe now I have finally found the answer I'm looking for, after reading all your suggestions and googling for additional info.

So, thanks guys, you all've been very helpful.

Best regards
Conway

-----Original Message-----
From: Jeffrey Janner [mailto:Jeffrey.Janner@PolyDyne.com] 
Sent: Saturday, 5 February 2011 11:55 a.m.
To: 'Tomcat Users List'
Subject: RE: Tomcat Service configuration for running sites

Chris -
I was working on the OP's original assumption of just getting his first webapp up in Tomcat.
I believe someone else had already suggested he look at the RUNNING.txt file for doing multiple instances.
But the OP wasn't originally asking about multiple instances of Tomcat, but running multiple webapps.
It appears to me he's unclear on the concept of the webapp, thus my suggestion to re-read all the documentation.
Perhaps you should re-read the OP's original post.
Jeff

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, February 04, 2011 4:39 PM
> To: Tomcat Users List
> Subject: Re: Tomcat Service configuration for running sites
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Jeffrey,
> 
> On 2/4/2011 10:06 AM, Jeffrey Janner wrote:
> > You don't need to duplicate the entire Tomcat structure for your
> > webapp.  Get rid of everything else in C:\WebApp1 except the ROOT and
> > sslcerts directory.  Then configure everything else in the C:\Tomcat
> > directory structure, particularly the server.xml file.  Change the
> > ROOT.xml file to point to C:\WebApp1\ROOT and you should be fine.
> 
> If he's using CATALINA_BASE, he will need the C:\WebApp1\conf directory
> to exist. It makes no sense whatsoever to configure multiple Tomcat
> instances with a single server.xml in CATALINA_HOME/conf.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk1MgAAACgkQ9CaO5/Lv0PCwagCfVpupXmkQEPSCjlUXezThMEMx
> b58AoL/3sYApDrtm9KEOxGOx/Nh2/dzD
> =tdyL
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.


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


RE: Tomcat Service configuration for running sites

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
Chris -
I was working on the OP's original assumption of just getting his first webapp up in Tomcat.
I believe someone else had already suggested he look at the RUNNING.txt file for doing multiple instances.
But the OP wasn't originally asking about multiple instances of Tomcat, but running multiple webapps.
It appears to me he's unclear on the concept of the webapp, thus my suggestion to re-read all the documentation.
Perhaps you should re-read the OP's original post.
Jeff

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Friday, February 04, 2011 4:39 PM
> To: Tomcat Users List
> Subject: Re: Tomcat Service configuration for running sites
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Jeffrey,
> 
> On 2/4/2011 10:06 AM, Jeffrey Janner wrote:
> > You don't need to duplicate the entire Tomcat structure for your
> > webapp.  Get rid of everything else in C:\WebApp1 except the ROOT and
> > sslcerts directory.  Then configure everything else in the C:\Tomcat
> > directory structure, particularly the server.xml file.  Change the
> > ROOT.xml file to point to C:\WebApp1\ROOT and you should be fine.
> 
> If he's using CATALINA_BASE, he will need the C:\WebApp1\conf directory
> to exist. It makes no sense whatsoever to configure multiple Tomcat
> instances with a single server.xml in CATALINA_HOME/conf.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk1MgAAACgkQ9CaO5/Lv0PCwagCfVpupXmkQEPSCjlUXezThMEMx
> b58AoL/3sYApDrtm9KEOxGOx/Nh2/dzD
> =tdyL
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.

Re: Tomcat Service configuration for running sites

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeffrey,

On 2/4/2011 10:06 AM, Jeffrey Janner wrote:
> You don't need to duplicate the entire Tomcat structure for your
> webapp.  Get rid of everything else in C:\WebApp1 except the ROOT and
> sslcerts directory.  Then configure everything else in the C:\Tomcat
> directory structure, particularly the server.xml file.  Change the
> ROOT.xml file to point to C:\WebApp1\ROOT and you should be fine.

If he's using CATALINA_BASE, he will need the C:\WebApp1\conf directory
to exist. It makes no sense whatsoever to configure multiple Tomcat
instances with a single server.xml in CATALINA_HOME/conf.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1MgAAACgkQ9CaO5/Lv0PCwagCfVpupXmkQEPSCjlUXezThMEMx
b58AoL/3sYApDrtm9KEOxGOx/Nh2/dzD
=tdyL
-----END PGP SIGNATURE-----

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


RE: Tomcat Service configuration for running sites

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
Conway, see inline comments below:

> -----Original Message-----
> From: Conway Liu [mailto:cliu@xtra.co.nz]
> Sent: Thursday, February 03, 2011 1:11 AM
> To: users@tomcat.apache.org
> Subject: Tomcat Service configuration for running sites
> 
> Hi,
> 
> Thanks to all who answered my previous post regarding running Tomcat
> with IIS7.
> 
> I am still quite confused about the whole thing, so I think I should
> try to
> forget about IIS for the time being, and concentrate first on how to
> get Tomcat
> service to serve a java website sitting physically outside of Tomcat's
> installed
> folder.
> 
> BTW, platform is Windows 2008 R2 64bit.
> Tomcat installed is 5.5.32. (In my previous question I installed 6.0.30
> but I
> now realised when the website was running on Linux, my manager was
> using 5.5.23
> and now I can only find 5.5.32 to download. I hope it makes no
> difference).
> 

With this platform, you need to be very careful.  If you run with the native libraries (APR), and you are using IPv4 addresses, you will need to specify the "address=" attribute in all your <Connector> tags in server.xml.  You'd need to do that anyway if running multiple instances, but you have to even for a single Tomcat instance on that platform.

> 
> For example, Tomcat service is installed on: (... means some more sub
> folders or
> files within):
> C:\Tomcat\
> 
> And the subfolders under this folder are:
> C:\tomcat\bin\...   (contains tomcat5.exe, tomcat5w.exe, and 3 .jar
> files)
> C:\tomcat\common\...
> C:\tomcat\conf\...   (contains catalina.policy, catalina.properties,
> context.xml, logging.properties, server.xml, server-minimal.xml,
> tomcat-users.xml, web.xml)
> C:\Tomcat\conf\Catalina\
> C:\Tomcat\conf\Catalina\localhost
> C:\tomcat\logs
> C:\tomcat\server
> C:\Tomcat\server\classes\
> C:\Tomcat\server\lib\...   (many .jar files in there, e.g.
> catalina.jar)
> C:\Tomcat\server\webapps\...
> C:\tomcat\shared\...
> C:\tomcat\temp
> C:\tomcat\webapps\ROOT\...
> C:\tomcat\work
> 
> My Java web application is placed in:
> C:\WebApp1\
> 
> With subfolders:
> C:\WebApp1\bin\...   (contains tomcat5.exe and tomcat5w.exe and many
> .sh and
> .bat files as we previously start this site using the startup.bat
> before I
> installed the Tomcat service)
> C:\WebApp1\common\...
> C:\WebApp1\conf\...   (contains catalina.policy, catalina.properties,
> context.xml, logging.properties, server.xml, server-minimal.xml,
> tomcat-users.xml, web.xml specifically used by this website)
> C:\WebApp1\conf\Catalina\
> C:\WebApp1\logs\
> C:\WebApp1\server\
> C:\WebApp1\server\lib\...   (many .jar files in there, e.g.
> catalina.jar)
> C:\WebApp1\shared\...
> C:\WebApp1\sslcerts\...   (SSL certificates in here)
> C:\WebApp1\webapps\ROOT\...   (This is the root of the website. E.g.
> default.jsp
> sits in here)
> C:\WebApp1\webapps\ROOT\WEB-INF\classes\...   (The java classes we
> created to be
> used for the website to interact with back-end database)
> C:\WebApp1\webapps\ROOT\WEB-INF\lib\...   (some 3rd party .jar files
> specifically used by this website)
> C:\WebApp1\webapps\ROOT\WEB-INF\web.xml   (contains the listener
> definition,
> points to the listener class, so that when this site starts the
> listener class
> can perform some initialisation tasks)
> C:\WebApp1\work
> 


You don't need to duplicate the entire Tomcat structure for your webapp.  Get rid of everything else in C:\WebApp1 except the ROOT and sslcerts directory.  Then configure everything else in the C:\Tomcat directory structure, particularly the server.xml file.  Change the ROOT.xml file to point to C:\WebApp1\ROOT and you should be fine.

Of course, re-reading the Tomcat documentation is highly suggested, as a number of your base assumptions are incorrect.

> 
> Question:
> 1. How should I configure Tomcat service so that it serves the WebApp1
> website?
> Which file in which folder to modify?
> 2. When Tomcat starts WebApp1 website, which set of configuration files
> is it
> using? (Those in C:\tomcat\conf\ or those in C:\WebApp1\conf\?)
> 3. If I am to add another website to the same server, say C:\WebApp2,
> with exact
> folder structure as WebApp1, how should I configure Tomcat service so
> that it
> serves both WebApp1 and WebApp2?
> 4. The two sites will use different IP addresses. For example WebApp1
> is
> 43.88.12.123, and WebApp2 is 43.88.12.133. How do I tell Tomcat which
> IP belongs
> to which website?
> 
> 
> Again, your input is very much appreciated.
> 
> Best regards
> Conway
__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.


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


Re: Tomcat Service configuration for running sites

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Conway,

On 2/3/2011 2:10 AM, Conway Liu wrote:
> Tomcat service is installed [in]:
> C:\Tomcat\

> My Java web application is placed in:
> C:\WebApp1\
>  
> With subfolders:
> C:\WebApp1\bin\...   (contains tomcat5.exe and tomcat5w.exe and many .sh and 
> .bat files as we previously start this site using the startup.bat before I 
> installed the Tomcat service)
> C:\WebApp1\common\...
> C:\WebApp1\conf\...   (contains catalina.policy, catalina.properties, 
> context.xml, logging.properties, server.xml, server-minimal.xml, 
> tomcat-users.xml, web.xml specifically used by this website)
> C:\WebApp1\conf\Catalina\
> C:\WebApp1\logs\
> C:\WebApp1\server\
> C:\WebApp1\server\lib\...   (many .jar files in there, e.g. catalina.jar)
> C:\WebApp1\shared\...
> C:\WebApp1\sslcerts\...   (SSL certificates in here)
> C:\WebApp1\webapps\ROOT\...   (This is the root of the website. E.g. default.jsp 
> sits in here)
> C:\WebApp1\webapps\ROOT\WEB-INF\classes\...   (The java classes we created to be 
> used for the website to interact with back-end database)
> C:\WebApp1\webapps\ROOT\WEB-INF\lib\...   (some 3rd party .jar files 
> specifically used by this website)
> C:\WebApp1\webapps\ROOT\WEB-INF\web.xml   (contains the listener definition, 
> points to the listener class, so that when this site starts the listener class 
> can perform some initialisation tasks)
> C:\WebApp1\work

This looks more like a whole Tomcat instance than just your webapp. Are
you expecting to use CATALINA_BASE to launch Tomcat from a shared
installation but in a multi-instance (even if "multi" only means "one")
environment?

> Question:
> 1. How should I configure Tomcat service so that it serves the WebApp1 website? 
> Which file in which folder to modify?

If the "website" is found in C:\WebApp1\webapps\ROOT then you should
only have to do one of the following:

C:\> C:\WebApp1\bin\startup.bat

or

C:\> SET CATALINA_BASE=C:\WebApp1
C:\> C:\Tomcat\bin\startup.bat

One of these should launch Tomcat and should not require any editing of
any configuration files from the stock install unless you want to change
your <Connector> to listed on a port other than 8080 for HTTP requests.

> 2. When Tomcat starts WebApp1 website, which set of configuration files is it 
> using? (Those in C:\tomcat\conf\ or those in C:\WebApp1\conf\?)

That depends on how you start Tomcat. If you start Tomcat by setting
CATALINA_BASE=C:\WebApp1 and then running C:\Tomcat\bin\startup.bat,
then you'll get C:\WebApp1 started. If you run the same command without
setting CATALINA_BASE, you'll get C:\Tomcat started. If you run
C:\WebApp1\bin\startup.bat (because C:\Tomcat and C:\WebApp1 are
essentially the same as you've described them), then you'll run C:\WebApp1.

Your set up looks like it's more complicated than it needs to be.

Might I recommend the following:

1. Move your webapp temporarily from C:\WebApp1\webapps\ROOT somewhere
   else
2. Completely remove C:\WebApp1
3. Create a new directory, C:\WebApp1
4. Re-read the "Advanced Configuration - Multiple Tomcat Instances"
   section of C:\Tomcat\RUNNING.txt, using C:\WebApp1 as CATALINA_BASE
5. Move your webapp back into C:\WebApp1\webapps

Always start Tomcat like this:

C:\> SET CATALINA_BASE=C:\WebApp1
C:\> C:\Tomcat\bin\startup.bat

Of, if you want to use Tomcat as a service (like most people on
Microsoft Windows want to do), then make sure that you set the
catalina.base property appropriately via the service installer interface.

> 3. If I am to add another website to the same server, say C:\WebApp2, with exact 
> folder structure as WebApp1, how should I configure Tomcat service so that it 
> serves both WebApp1 and WebApp2?

If you want to serve two webapps from the same Tomcat install, then just
drop the second website into a subdirectory of C:\WebApp1\webapps. If
you want it to be the ROOT webapp of a different hostname, you'll have
to create multiple <Host> entries in server.xml, each with a different
"webapps" folder and put one ROOT in each one.

> 4. The two sites will use different IP addresses. For example WebApp1 is 
> 43.88.12.123, and WebApp2 is 43.88.12.133. How do I tell Tomcat which IP belongs 
> to which website?

The <Connector> element takes an "address" attribute which can bind to a
specific IP. If you really only want a one-to-one mapping between IP
addresses and webapps, you'll have to create two separate <Service>
configurations, each with a <Connector> and <Host>.

If you don't mind serving the same content to all IP addresses, it's
generally much easier to have a single <Connector>, a single default
<Host>, and multiple webapps deployed into it.

You can probably do this (eventually) with IIS, but I know for a fact
that you can mangle URL spaces with Apache httpd's mod_proxy so you can
take a webapp deployed into Tomcat at http://host:8080/webapp1 and serve
it from httpd as http://webapp1.host.com/ while http://webapp2.host.com/
goes to http://host:8080/webapp2.

If you give me a little more information about your actual requirements,
I can tell you which of the above is most appropriate (IMO).

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1LFOcACgkQ9CaO5/Lv0PBBOACcDdm5faSWXEoPPe0EO7KoBQI6
pwwAoLp2mk9QOKXvOFjgyB+vmfaZd40/
=Ybf8
-----END PGP SIGNATURE-----

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