tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Is this common behavior in Apache Tomcat? (cPanel install of Tomcat 5.5)
Date Sun, 12 Sep 2010 12:50:37 GMT
Carlo del Mundo wrote:
> I realized the problem indirectly as I wrote this e-mail; thanks for your
> quick response also.
> 
> I went to my httpd.conf for Apache, found the VirtualHost entry to my
> Servlet, to find that my application was not "automagically" listed under
> JkMount.
> 
> I manually added it, and voila it works.
> 
> Can you answer me this however... for every WAR I want to install, I must
> manually add it to the httpd.conf virtual hosts entry? 
> 
Hi.

Short answer : yes.

Medium answer : yes, because the "JkMount /something" directive in httpd.conf, is the way

whereby the Apache add-on module mod_jk "learns" that it must forward to Tomcat the 
requests which match this URL.

Longer answer :
It works approximately like this :

A) during Apache startup:

When Apache (httpd) loads an add-on module (like mod_jk), it calls an initialisation 
procedure in this module.  This procedure tells Apache  which configuration directives it

is interested in (in this case, this would be a list including JkMount, JkUnMount, etc..).

Later, when Apache scans the httpd.conf, when it finds such a directive, it calls another

procedure in the add-on module to actually process the directive.
So for example, when Apache finds a directive "JkMount" later in the httpd.conf file, it 
calls mod_jk to handle this.  And when mod_jk is called, with "JkMount /something" as a 
parameter, it internally builds a table, of all the URL patterns which it should later handle.

B) later at run-time:

Whenever Apache receives a request, it will look at all the "handlers" it has for 
processing that request.  Then it will pass the request to each possible handler in turn.
A called handler can decide to process the request and generate a response for it, or to 
decline. If it declines, Apache will call the next handler and so on, until one generates

a response.
mod_jk is one of these handlers, so it gets called for each request, and can examine the 
request to see if he wants to handle it.  If the request URL matches one of the URLs that

were specified earlier by one of the JkMount directives, mod_jk will handle it, and will 
generate the response to that request.
(For Apache thus, it is mod_jk which generates the response;  Apache itself has no idea 
that mod_jk is "cheating", and actually passing this request to another process (Tomcat) 
to generate the response.)

Tip answer :
I do not think that you can dynamically add new URL patterns to the internal table of 
mod_jk.  But you can make use of Apache's "include" and "reload" capabilities to get 
something similar.

When you tell Apache to reload its configuration (e.g. under most Linuxes : 
"/etc/init.d/apache2 reload"), it re-reads all its configuration files, and goes through 
the process described above in (A).
You can tell Apache to include in this configuration, all the files located in some 
directory (e.g. "Include /etc/apache2/mods-enabled/*.conf").

In your case thus, you could set up your deployment script to automatically create a small

file in some Apache configuration directory (e.g. "/etc/apache2/tomcat_apps"), this file 
containing a list of JkMount directives, like :
JkMount /myapp1
JkMount /myapp1/*
JkMount /myapp2
JkMount /myapp2/*
...
JkMount /mynewapp
JkMount /mynewapp/*

then add in httpd.conf the following line :
Include /etc/apache2/tomcat_apps/*

then force an Apache reload.

You need to adapt the above in function of your Virtual Hosts, so that each host gets 
"his" tomcat apps (the "Include" can be in a VirtualHost section).


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


Mime
View raw message