<?xml version="1.0"?>
<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>
<document url="faq.html">

  &project;
<copyright>
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
</copyright>
<properties>
<title>Frequently Asked Questions</title>
<author email="hgomez@apache.org">Henri Gomez</author>
</properties>
<body>
<section name="General">
<p>
General Informations and FAQ about JK
</p>
<subsection name="Where can I get help/support for JK ?">
<p>
The primary mechanism for support is through the JK 
documentation included in the doc directory.
Documentation is also available on the Apache Tomcat web site devoted to the
<a href="http://tomcat.apache.org/connectors-doc/">
Apache Tomcat Connectors Project</a>
For additional help, the best resource is the Tomcat Users Discussion list.  
You should start by searching
<a href="http://mail-archives.apache.org/mod_mbox/tomcat-users/">
the mail list archive</a>
before you post questions to the list.  
If you are unable to locate the answer to your question in the archive, 
you can post questions about JK to the user list for assistance.  
Make sure that you include the version of your web server, 
that you are using as well as the platform you are running on
and go 
<a href="http://tomcat.apache.org/lists.html">
here</a>
to determine how to subscribe to tomcat mailing list.
</p>
</subsection>

<subsection name="I can't find JK anywhere. Where is it?">
<p>
Now that JK moved to the <b>tomcat-connectors</b> repository, 
the source and the binaries for JK can be downloaded from a mirror at the
<a href="http://tomcat.apache.org/download-connectors.cgi">
Tomcat Connectors (mod_jk, mod_jk2) Downloads</a> page.
</p>
</subsection>

<subsection name="What's the difference between JK and mod_jk ?">
<p>
<b>JK</b> is a project covering web servers to Tomcat connectors.
</p>
<p>
<a href="../webserver_howto/apache.html">Apache HTTP Server</a> support is implemented on JK, using a plugin
called the <b>mod_jk module</b>.
</p>

<p>
<a href="../webserver_howto/iis.html">Microsoft IIS</a> support is implemented on JK, using a plugin
called the <b>ISAPI redirector</b>.
</p>

<p>
<a href="../webserver_howto/nes.html">iPlanet Web Server</a> support is implemented on JK, using a plugin
called the <b>NSAPI redirector</b>.
</p>

</subsection>

<subsection name="Where can I get more information ?">
<p>
For <b>JK 1.2.x</b>, you should read:
</p>

<ul>

<li>
<a href="../common_howto/quick.html">Quick Start</a>
</li>

<li>
<a href="../webserver_howto/apache.html">Apache HTTP Server and JK (mod_jk)</a>
</li>

<li>
<a href="../webserver_howto/iis.html">Microsoft IIS and JK (ISAPI redirector)</a>
</li>

<li>
<a href="../webserver_howto/nes.html">iPlanet Web Server and JK (NSAPI redirector)</a>
</li>

<li>
<a href="../common_howto/workers.html">Workers configuration</a>
</li>
</ul>

<p> 
For more detailed information, have a look at the Reference Guide.
You could also try searching the mailing list archives for "JK" or look at the source.
</p>
</subsection>

<subsection name="Which protocol should I use - ajp12, ajp13 or ajp14?">
<p>
<a href="../ajp/ajpv13a.html">ajp13</a> is the standard. The old
<strong>ajp12 is deprecated</strong> and <strong>ajp14 is experimental</strong>.
</p>
<p> 
Also ajp13 is supported by all Apache Tomcat versions starting with Tomcat 3.2
and by other servlet engines like <b>Jetty</b> and <b>JBoss</b>.
</p>
</subsection>

<subsection name="I've got a firewall between my web server and Tomcat which drops ajp13 connections after some time">
<p>
The ajp13 protocol uses persistant connections where the traffic could be null if there is no request to be sent to Tomcat. 
Firewalls use to drop inactive connections and will make your web server and Tomcat think the connection is valid. 
</p>
<p>
Starting with JK 1.2.0, a <b>socket_keepalive</b> property as been added to ajp13 settings, and you should take a look at 
it in <a href="../common_howto/workers.html">Workers HowTo</a> and
<a href="../reference/workers.html">workers.properties reference</a>.
If nothing else helps, you can try <b>JkOptions +DisableReuse</b>, but this will have strong performance implications.
</p>
</subsection>

<subsection name="Under heavy load, I've got many threads in Tomcat even if my Apache HTTP Server handles much of the load">
<p>
Under heavy load, the Apache HTTP Server creates many children to handle the load,
which will in turn create many connections 
to Tomcat to forward the requests they should handle. 
The Apache HTTP Server will normally kill the children/threads when the load decreases.
But if the load is still there and even if only Apache handles the requests,
ie static contents, the children are kept and with them all the ajp13 connections, 
even if they are no more used. 
</p>
<p>
To close connections after some time of inactivity you can use <b>connection_pool_timeout</b>,
for more informations refer to <a href="../reference/workers.html">workers.properties reference</a>.
</p>
</subsection>

</section>

<section name="Apache HTTP Server">
<p>
Informations and FAQ about mod_jk and the Apache HTTP Server. 
</p>
<subsection name="Whenever I restart Tomcat, Apache locks up!">
<p>
The ajp13 protocol keeps an open socket between Tomcat and Apache.
Release of mod_jk present in Tomcat Connectors handles the network failure. 
But with very ancient releases of mod_jk, you may have to restart Apache as well.
</p>
</subsection>

<subsection name="Why do there exist two files mod_jk.so (-eapi ad -noeapi) in download directories for Apache 1.3?">
<p>
Many versions of Apache use a modified API, known at Extended API, developed for use with the
<a href="http://www.modssl.org">mod_ssl module</a>. Starting with Apache 2.0 there is no more difference.
</p>

<p>
For example, Apache 1.3 present in certains recent Linux distributions include the
<b>mod_ssl</b> module.
</p>

<p>
So if you got such 'Extended Apache', you need to use <b>mod_jk.so-eapi</b>.
</p>

<p> 
You should use <b>mod_jk.so-noeapi</b> only for 'Standard Apache' (ie without mod_ssl).
</p>

<p>
It's wise to avoid using EAPI modules on STD API Apache or to use standard API modules on EAPI Apache. 
Allways be sure to have the <b>mod_jk.so</b> which match your version of Apache.
</p>
</subsection>

<subsection name="What's that message about 'garbled DSO ?'">
<p>
It's related to Apache EAPI, the message <code>'mod_jk.so is garbled - perhaps this is not an Apache module DSO ?'</code> 
just told you, that your're trying to install a mod_jk.so DSO module that was compiled on an Apache using EAPI, 
like apache-mod_ssl or apache from Redhat distro 6.2/7.0 but your system use the standard Apache with normal API.
</p>
</subsection>

<subsection name="And the message about 'module might crash under EAPI!">
<p>
Also related to EAPI, the message <code>'[warn] Loaded DSO /usr/lib/apache/mod_jk.so uses plain Apache 1.3 API, 
this module might crash under EAPI! (please recompile it with -DEAPI)'</code>, the mod_jk.so was compiled under normal 
Apache with standard API and you try to install the module on an Apache using EAPI.
</p>
</subsection>

<subsection name="APXS is getting an error during the build of mod_jk, like rc=0 or rc=255.  I tried all of the steps in the build section, what do I do now ?">
<p>
APXS is a Perl script that is created when you build the Apache web server from source.  
Chances are that if you are getting these errors and you obtained Apache as a binary distribution, 
that APXS is not configured correctly for your system.  
Your best bet is to get the Apache source from the <a href="http://httpd.apache.org/">Apache HTTP Server homepage</a> and build it yourself.  
Use the following for a basic build (read the Apache docs for other options):
<source>[user@host] ~ $ cd /usr/local/src
[user@host] ~ $ gzip -dc apache_1.3.19.tar.gz|tar xvf -
[user@host] ~ $ cd apache_1.3.19
[user@host] ~ $ ./configure --prefix=/usr/local/apache \
            --enable-module=most \
            --enable-shared=max
[user@host] ~ $ make
[user@host] ~ $ make install
</source>
</p>
<p>
Note: The above steps assume that you downloaded the Apache source and placed it in your /usr/local/src directory.
</p>
</subsection>

<subsection name="Apache complains about incorrect module version">
<p>
Since the Apache API can change between versions, any Apache module contains the
Apache API version used to compile the module. This is called the Magic Module Number.
</p>
<p>
At start time Apache checks that the version in the module header is compatible
with the Apache server. If not it will deny to start and log an error.
</p>
<p>
Note that minor versions are forward compatible. If the module was compiled using
Apache 2.x.y the resulting binary should work with any other version 2.x.z where z
is bigger or equals to y. If you also need compatibility for versions 2.x.z
with z smaller than y, use the configure flag --enable-api-compatibility. Note
that the module compiled with any 2.x will never be compatible with 2.y for
x different from y. In this case you need to recompile the module.
</p>
</subsection>

<subsection name="Does it work for the latest Apache 2.x?">
<p>
mod_jk works well with Apache 2.x from 2.0 to 2.4.
</p>
<p>
Important parts of the functionality of mod_jk have been reimplemented in the Apache HTTP Server modules mod_proxy_ajp
and mod_proxy_balancer. These are part of the standard distribution of Apache 2.2 and 2.4. The new modules do not contain
all features of mod_jk, but on the other hand you get the modules automatically with every new Apache release.
</p>
</subsection>

<subsection name="JNI doesn't work with Apache 1.3">
<warn>JNI workers have been deprecated. They will likely not work. Do not use them.</warn>
<p>
JNI support requires a multi-threaded environment which is not the general case for Apache 1.3. 
You should verify if Apache 1.3 has been build with thread support and if not you could add the 
the pthreads library to your <b>httpd.conf</b> file. 
</p>

<source># Add pthread to Apache in httpd.conf
LoadModule "/usr/lib/libpthreads.so"
</source>

<p>
Also keep in mind that JNI is suited for multi-threaded servers and you should consider upgrading 
to Apache 2.x to support JNI.
</p>
</subsection>

<subsection name="JNI report that JVM couldn't be started under Linux">
<warn>JNI workers have been deprecated. They will likely not work. Do not use them.</warn>
<p>
Under Linux, you should set some environment variables BEFORE launching your Apache HTTP Server:
</p>

<source>export LD_LIBRARY_PATH=$jre/bin:$jre/bin/classic:$LD_LIBRARY_PATH
</source>

<p>
Also some Linux distributions have enabled a GLIBC feature called 'floating stacks' which may not works with kernel 
less than 2.4.10 on SMP machines. You should disable floating stacks by exporting an environment variable:
</p>

<source>export LD_ASSUME_KERNEL=2.2.5
</source>

<p>
You could have to update your service scripts, ie <b>/etc/rc.d/init.d/httpd</b>, to set these env vars 
before your Apache server starts.
</p>
</subsection>

<subsection name="Mixed errors when building via configure">
<p>
configure assume you have some GNU tools already installed and configured for your system, and ad minima <b>libtool</b>.
</p>
<p>
Also some systems may have mixed cc and gcc setup which may make you puzzled when trying to link an Apache built with native
c compiler with a jk/jk2 build with gcc.
</p>
<p>
In case the make processing doesn't work as expected, you should use a GNU make <b>gmake</b>.
</p>
</subsection>

</section>
</body>
</document>
