Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Tomcat 4.x, Apache and Windows

Configure Tomcat and Apache using mod_webApp on Win32 by baden
Posted: 7 Feb 02

After many headaches of the install I didn't want this little piece of knoledge to go to waste - it may help someone, somewhere.

February 7, 2002

Configuring Apache to use the Tomcat JSP/Servlet Container Using the mod_webApp Connector

This document details how to configure Tomcat 4.0.1 with Apache Web Server v1.3.23 on a Windows 2000 platform.

[* ! *] Important note:  Using the mod_webApp connector under a Windows environment has proven to be flaky.  Specifically, an error like the following has been reported:
WebApp: Error 500
(File: pr_warp.c Line: 434)

Please send me your comments to   baden@pmcanada.com

Apache directives: http://httpd.apache.org/docs/mod/core.html

You may be aware of a few modlues such as mod_jk and mod_webapp.  The mod_jk package makes use of  $TOMCAT_HOME/conf/worker.properties, which is not created by Tomcat 4, and needs to be created manually.

First we need to configure Tomcat.  You may have to add the following lines after the last </Service> tag in $CATALINA_HOME/conf/server.xml:
# =================== C U T =================
<!-- The MOD_WEBAPP connector is used to connect Apache 1.3 with Tomcat 4.0
       as its servlet container. Please read the README.txt file coming with
       the WebApp Module distribution on how to build it.
       (Or check out the "jakarta-tomcat-connectors/webapp" CVS repository)

       To configure the Apache side, you must ensure that you have the
       "ServerName" and "Port" directives defined in "httpd.conf".  Then,
       lines like these to the bottom of your "httpd.conf" file:

         LoadModule webapp_module libexec/mod_webapp.so
         WebAppConnection warpConnection warp localhost:8008
         WebAppDeploy examples warpConnection /examples/

       The next time you restart Apache (after restarting Tomcat, if needed)
       the connection will be established, and all applications you make
       visible via "WebAppDeploy" directives can be accessed through Apache.

       Refer to http://dcb.sun.com/practices/howtos/tomcat_apache.jsp for additional help.
  <!-- Define an Apache-Connector Service -->
<Service name="Tomcat-Apache">

    <Connector className=
            port="8008" minProcessors="5" maxProcessors="75"
                    acceptCount="10" debug="0"/>
<!-- Replace "localhost" with what your Apache "ServerName" is set to -->
    <Engine className=
             name="localhost" debug="0" appBase="webapps">

      <!-- Global logger unless overridden at lower levels -->
      <Logger className= "org.apache.catalina.logger.FileLogger"
              prefix="apache_log." suffix=".txt" timestamp="true"/>

      <!-- Because this Realm is here, an instance will be shared globally -->
      <Realm className="org.apache.catalina.realm.MemoryRealm" />

# =================== C U T =================
Refer to http://dcb.sun.com/practices/howtos/tomcat_apache.jsp for additional help.

The mod_webapp Connector

Next, locate the file íºwebapp-module-1.0-tc40í¿ íV http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/win32/webapp-module-1.0-tc40-windows.zip

*** Refer to the enclosed install.txt for additional assistance.

Copy the mod_webapp.so and the libapr.dll file you will find in this into $APACHE_HOME/modules.

Add the following directives.  For Windows your "LoadModule" directive looks like (in httpd.conf):
This should go in the section that contains (around line 185):
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
#LoadModule status_module modules/mod_status.so
#LoadModule info_module modules/mod_info.so

The directive should look like this:
    #Directive descriptioníK
LoadModule webapp_module modules/mod_webapp.so

Next, down at around line 250:
#AddModule mod_usertrack.c
#AddModule mod_unique_id.c
AddModule mod_so.c
AddModule mod_setenvif.c

The following directive should be added:
#Directive description
AddModule mod_webapp.c

As install.txt indicates, commenting out the AddModule line may fix a problem experienced when loading the server, although the configtest option will return the line number in the configuration file where the error was encountered.

Next, run a syntax check to ensure that these configurations work with Apache:
$APACHE_HOME/apache -t

íº$APACHE_HOME/conf/httpd.conf: Syntax OKí¿ return value should be returned, indicating that the configuration is correct.

Now, start adding the web application connections and context into the Apache configurations.
Back to the "httpd.conf" file.  Locate the section where the <IfModule  > starts.
Somewhere after a <IfModuleíK>íK</IfModuleíK> block add the following block:
<IfModule mod_webapp.c>
WebAppConnection warpConnection warp localhost:8008
WebAppInfo   /webapp-info
WebAppDeploy examples warpConnection /examples
WebAppDeploy webdav warpConnection /webdav
WebAppDeploy tomcat-docs warpConnection /tomcat-docs

The IfModule directive can be omitted.

Tomcat has a /manager command to load and unload servlets, etc., and list what is loaded in its environment.  A WebApp cannot be created for this, ie:
    WebAppDeploy manager warpConnection /manager
It will authenticate on whatever realm it is setup with, but will return a server error after this.

The JSP/Servlet container (Tomcat) should be listening on the port specified in the socket íºlocalhost:xxxxí¿.  The webApp connects requests to this port.  This is not the http port, it is the port that the WARP connector is listening on, as specified in $CATALINA_HOME/conf/server.xml.

Run $APACHE_HOME/apache -t again to make sure that there are no errors with httpd.conf.

*** We can add a virtual host for this, which is entirely optional.  

Create a new virtual host by adding the line:
äh NameVirtualHost
- instead of the loopback address, insert whatever IP address you are using.

Next we need to define that virtual host by adding the following:
 ServerName crystal
  DocumentRoot "C:/JAVADEV/Apache Group/Apache Tomcat 4.0/x"
  WebAppConnection warpConnection warp localhost:8008
  WebAppDeploy examples warpConnection /examples
  ErrorLog logs/warpConnection-error_log.txt

Run $APACHE_HOME/apache -S (it must be a capital "S") to view the virtual-host configuration, and ensure there are no problems.

document end

Back to Linux (server) FAQ Index
Back to Linux (server) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close