<?xml version="1.0" encoding="UTF-8"?>
<!--
  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.
-->
<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>
<document url="index.html">

  &project;

  <properties>
    <author email="jfclere@apache.org">Jean-Frederic Clere</author>
    <title>Documentation Index</title>
  </properties>

<body>

<section name="Introduction">

  <p>
    The Apache Tomcat Native Library is an optional component for use with
    Apache Tomcat that allows Tomcat to use certain native resources
    for performance, compatibility, etc.
  </p>

  <p>
    Specifically, the Apache Tomcat Native Library gives Tomcat access to
    the Apache Portable Runtime (APR) library's network connection (socket)
    implementation and random-number generator.
    See the Apache Tomcat documentation for more information on how to
    configure Tomcat to use the APR connector.
  </p>

  <p>
    Features of the APR connector:
  </p>
  <ul>
    <li>Non-blocking I/O for Keep-Alive requests (between requests)</li>
    <li>Uses OpenSSL for TLS/SSL capabilities (if supported by linked APR library)</li>
    <li>FIPS 140-2 support for TLS/SSL (if supported by linked OpenSSL library)</li>
  </ul>


<p>Select one of the links from the navigation menu (to the left) to drill
down to the more detailed documentation that is available. Each available
manual is described in more detail below.</p>

</section>

<section name="Headlines">
<ul>

<li><a href="news/2016.html#20160702">2 July 2016 - <b>TC-Native-1.2.8 released</b></a>
<p>The Apache Tomcat team is proud to announce the immediate availability of
Tomcat Native 1.2.8 Stable.</p>
<p>
The sources and the binaries for selected platforms are available from the
<a href="../download-native.cgi">Download page</a>.
</p>
<p>
Please see the <a href="miscellaneous/changelog.html">ChangeLog</a> for a full
list of changes.
</p>
</li>
</ul>
</section>

<section name="Building">
<subsection name="Requirements">
    <p>
      Build tc-native requires three components to be installed:
    </p>
      <ul>
        <li>APR library</li>
        <li>OpenSSL libraries</li>
        <li>Java SE Development Kit (JDK)</li>
      </ul>

    <p>
      In debian based Linux those dependencies could be installed by something like:
    </p>
    <source>apt-get install libapr1.0-dev libssl-dev</source>
    <p>
      In rpm based Linux those dependencies could be installed by something like:
    </p>
    <source>yum install apr-devel openssl-devel</source>
</subsection>

<subsection name="UNIX">
  <p>
    On all the POSIX systems (Linux, Solaris, HP-UX, AIX etc...) a well-known
    configure and make is used to build tc-native.<br/>
    In the jni/native runs:
  </p>
    <source>./configure --help</source>
    <p>to read the description of all the parameters.</p>
    <source
>./configure --with-apr=$HOME/APR \
            --with-java-home=$JAVA_HOME \
            --with-ssl=$HOME/OPENSSL \
            --prefix=$CATALINA_HOME</source>
  <p>
    to create the includes and makefiles to be able to build tc-native.<br/>
    Where:<br/>
    <code>$HOME/APR</code> is something like /usr/bin/apr-1-config or the path where apr is
    installed.<br/>
    <code>$JAVA_HOME</code> is something /home/jfclere/JAVA/jdk1.5.0_09 path to a JDK
    installation. Any JDK should work but it is advisable to use the same
    JVM version the JVM you use with Tomcat.<br/>
    <code>$HOME/OPENSSL</code> is the path where OpenSSL is installed.<br/>
    <code>$CATALINA_HOME</code> is the path where the produced libraries will be
    installed. Something like $HOME/apache-tomcat-6.0.16/<br/>
    <br/>
    The configure is able to guess most of OpenSSL standard installations.
    So most of the time the following will be enough:
  </p>
    <source
>./configure --with-apr=/usr/bin/apr-1-config \
            --with-java-home=/home/jfclere/JAVA/jdk1.5.0_09/ \
            --with-ssl=yes \
            --prefix=$CATALINA_HOME</source>
  <p>
    To build the libraries and install them:
  </p>
  <source>make &amp;&amp; make install</source>
  <p>
    The libraries will be found in $CATALINA_HOME/lib
  </p>
</subsection>

<subsection name="Windows">
  <p>
   Download the windows sources of tc-native and extract them.
  </p>
  <p>
    Download OpenSSL sources (See <a href="http://www.openssl.org/related/binaries.html"><b>Binary Distributions</b></a>)
    OpenSSL is a crypto software so check if you are allowed to download it. If not you can still use tc-native without SSL.
  </p>
  <p>
    Download APR sources for Windows. (See <a href="http://apr.apache.org/download.cgi"><b>Download</b></a>)
    Extract them in jni and rename the apr-1.x.y directory to apr.
  </p>
  <p>
    Use MS Visual Studio to open the workspace of the APR sources and build the library (libapr).
  </p>
  <p>
    Use MS Visual Studio to open the workspace of the tc-native sources, adjust the OpenSSL includes and libraries location
    change the name of the libraries libeay32 and libssleay to libeay32MT and libssleayMT and build the tcn-native library.
    That should create a tcnative-1.dll.
  </p>
</subsection>

</section>

<section name="Install and tests">
  <subsection name="Configuring Tomcat">
    <p>
      Apache Tomcat comes with the <code>AprLifecycleListener</code> enabled
      by default. Still, you should check your <code>conf/server.xml</code>
      to ensure that something like the following is present, and uncommented:
    </p>

    <source wrapped="true"
      ><![CDATA[<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />]]></source>
    <p>
      Please see the Apache Tomcat documentation for configuration specifics.
    </p>
  </subsection>

<subsection name="UNIX">
  <p>
   Edit $CATALINA_HOME/bin/setenv.sh (creating the file if necessary) and add
   the path to the tc-native libraries to LD_LIBRARY_PATH. Something like:
  </p>
  <source>LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib
export LD_LIBRARY_PATH</source>
  <p>
   Start tomcat and check for the messages like this ones:
  </p>
   <source wrapped="true"
>Feb 8, 2015 12:27:41 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.x.y.
Feb 8, 2015 12:27:41 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Feb 8, 2015 12:27:41 PM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080</source>
  <p>
    Refer to the tomcat documentation to configure the connectors
    (See <a href="http://tomcat.apache.org/tomcat-8.0-doc/apr.html">Tomcat 8.0.x</a>,
    <a href="http://tomcat.apache.org/tomcat-7.0-doc/apr.html">Tomcat 7.0.x</a>
    and <a href="http://tomcat.apache.org/tomcat-6.0-doc/apr.html">Tomcat 6.0.x</a>)
  </p>
</subsection>

<subsection name="Windows">
  <p>
    Edit $CATALINA_BASE\bin\setenv.bat (creating the file if necessary) and add
    the path to the tc-native libraries, apr and OpenSSL to PATH. For example:
  </p>

  <source wrapped="true"
    >set PATH=%PATH;C:\cygwin\home\support\tomcat-native-current-win32-src\jni\native\Debug;C:\cygwin\home\support\tomcat-native-current-win32-src\jni\apr\Debug;C:\OpenSSL\lib\VC</source>
  <p>
    Start tomcat and check for the messages like this ones:
  </p>
  <source wrapped="true"
>Feb 8, 2015 2:48:17 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.x.y.
Feb 8, 2015 2:48:17 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [false], sendfile [true], accept filters [false], random [true].
Feb 8, 2015 2:48:18 PM org.apache.coyote.http11.Http11AprProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080</source>

</subsection>

</section>

</body>
</document>
