-----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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to