The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

8. Jakarta Tomcat

8.1. What is Tomcat


Tomcat is the servlet container that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the Java Community Process.

From the authors point of view: 

Tomcat is the successor of jserv which is no longer developed. Tomcat supports the latest jsp and servlet-APIs defined by sun. Unfortunately Tomcat is very difficult to build from source, because it is using its own building-system called "ant". There is also a very long list of prerequisites if you want to build from source. See for more details - Good luck, and give some feedback to the author.

In the meantime the HOWTO is providing some basic support for Tomcat installed from binaries.

The Author is searching for some volunteers who tries to build Tomcat from source and tells what steps are required

8.2. Prerequisites

8.2.1. Java2 What is Java2

Please see

Too much for this HOWTO, please see

8.2.2. Download the binaries

Go to [1],choose your platform and follow the steps on the site.

8.2.3. Installing the binaries

Execute the binary:
chmod +x j2sdk-1_3_1_02-linux-i386.bin


After accepting the license, unpack the stuff and move the resulting directory to /usr/lib and set an appropriate symbolic link

8.3. Download the binaries


8.3.1. Installing the binaries

cd /usr/local

tar -xvzf jakarta-tomcat-4.1.8.tar.gz

cd jakarta-tomcat-4.1.8

cd bin

rm *.bat

echo export JAVA_HOME=/usr/lib/java/ >> /etc/profile
. /etc/profile

To enable the Tomcat manager, you need to modify /usr/local/jakarta-tomcat-4.1.8/conf/tomcat-users.xml add a user ╩admin╚ or with the role ╩manager╚. The result should look like this:

<?xml version='1.0' encoding='utf-8'?>
  <role rolename="manager"/>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="admin" password="secret" roles="manager"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>

Now you should be able to startup tomcat:

You should now be able to connect to: http://localhost:8080/index.jsp

8.4. mod_jk

8.4.1. Download the source

If you like to have a native interface into your Apache Webserver, you need to build mod_jk with must be downloaded separately here:

8.4.2. Building and installing

tar -xvzf jakarta-tomcat-connectors-4.1.18-src.tar.gz

cd jakarta-tomcat-connectors-4.1.18-src/jk/native

./configure --with-apxs=/usr/local/apache/bin/apxs

make install

8.4.3. Customizing

Now follows the annoying part, the customizing of the config files. First edit /usr/local/jakarta-tomcat-connectors-4.1.18-src/jk/conf/, and copy the file to /usr/local/apache/conf

I made a sample that works with the example JSPs and servlets that comes with the Tomcat distribution. It is based on the sample from Tomcat

Example 8.


# workers.java_home should point to your Java installation. Normally
# you should have a bin and lib directories beneath it.

# You should configure your environment slash... ps=\ on NT and / on UNIX
# and maybe something different elsewhere.

# The workers that your plugins should create and work with

#------ DEFAULT ajp13 WORKER DEFINITION ------------------------------
# Defining a worker named ajp13 and of type ajp13
# Note that the name and the type do not have to match.

#------ CLASSPATH DEFINITION -----------------------------------------
# Additional class path components.

# The JVM that we are about to use
# Unix - Sun VM or blackdown

# Setting the place for the stdout and stderr of tomcat

Next, you need to configure your apache config file httpd.conf. The following example matches the examples provided by Tomcat.

LoadModule jk_module libexec/
AddModule mod_jk.c

JkWorkersFile /usr/local/apache/conf/
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /examples/servlet/* worker1
JkMount /examples/*.jsp worker1 

After restarting Apache, you should now be able to connect to your JSP's via Apache. I.e: http://localhost/examples/jsp/num/numguess.jsp

For the further steps like installing your servlets and jsp-files, you are responsible by yourself...

TipEnvironment Variables

If Tomcat fails to start and/or your servlets could not be started the most common error made is having not all needed classes in the CLASSPATH variable.



There is also version 1.4.1 of Java available, but Tomcat seems not to run with that version of Java.

Inferno Solutions
Hosting by

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру