DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Apache Software Foundation | Jakarta Project | Apache Tomcat

Quick Start JK2 Configuration Guide

Printer Friendly Version
print-friendly
version
Introduction

This document describes the configuration files used by JK2 on the Tomcat and Web Server side:

  • jk2.properties is used on the Tomcat side. It's installation path in the $TOMCAT_HOME/conf directory.
  • workers2.properties is used on the webserver side. For the Apache servers the default path is in the ServerRoot/conf directory.
Although JK2 has many things in common with mod_jk, the configuration is quite different, and all the directives should be inside the workers2.properties. This enables JK2 to have the same configuration file no mater what the web server it's connected to.


Minimum Configuration

Minimum configuration is the simplest one to make the JK2 working. The used channel will be socket, and lot of options are used by default. Both the Tomcat and web server are on the same computer.

jk2.properties:

# The default port is 8009 but you can use another one
# channelSocket.port=8019
That is all needed on the Tomcat side to configure the JK2.

workers2.properties:

# Define the communication channel 
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
tomcatId=localhost:8009

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
info=Map the whole webapp

Start the Tomcat and Web server and browse to the http://localhost/examples/


Minimum JNI Configuration

Minimum JNI configuration is the simplest one to make the Tomcat working from inside the web server as inprocess. The only comunication channel used is JNI. The JK2 will register all the native calls by itself, so there is no need to specify the native library on Java side.

jk2.properties:

# Add the apr and channelJni to the list of handlers
handler.list=apr,request,container,channelJni
# The native libraries will be registered by JK2
apr.jniModeSo=inprocess

workers2.properties:

# Define the comunication channel 
[channel.jni:jni]
info=The jni channel, used if tomcat is started inprocess

# Define the parameters for the Java Virtual Machine
[vm:]
info=Parameters used to load a JVM in the server process
OPT=-Djava.class.path=${TOMCAT_HOME}/lib/tomcat-jni.jar;${TOMCAT_HOME}/lib/tomcat.jar
OPT=-Dtomcat.home=${TOMCAT_HOME}
OPT=-Dcatalina.home=${TOMCAT_HOME}
OPT=-Xmx128M

# JNI worker startup handler
[worker.jni:onStartup]
info=Command to be executed by the VM on startup. This one will start tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=start
stdout=${serverRoot}/logs/stdout.log
stderr=${serverRoot}/logs/stderr.log

# JNI worker shutdown handler
[worker.jni:onShutdown]
info=Command to be executed by the VM on shutdown. This one will stop tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=stop

# Map the Tomcat examples webapp to the Web server uri space
[uri:/examples/*]
info=Map the whole webapp

Start the Web server and browse to the http://localhost/examples/