Login

Language :
TitleApache Portable Runtime (APR) based Native library for Tomcat
Apache Portable Runtime (APR) based Native library for Tomcat
Writer이지섭Write DateJan 16 2018Modify DateAug 30 2024View Count4616

Apache Portable Runtime (APR) based Native library for Tomcat 


Tomcat can also be used immediately after unpacking the downloaded .zip or .tar.gz compressed files.

In a Linux environment, the bin folder is located just below the Tomcat installation folder, which contains the tomcat-native.tar.gz file.

This is Apache Portable Runtime (APR) based Native library for Tomcat.

Linux has the following requirements for using this library :

Requirements:

  1. APR 1.2+ development headers (libapr1-dev package)
  2. OpenSSL 1.0.2+ development headers (libssl-dev package)
  3. JNI headers from Java compatible JDK 1.4+
  4. GNU development environment (gcc, make)


If you uncompress the Tomcat and use it immediately, it does not link to APR.

If you unpack the tomcat-native.tar.gz file and go to the native folder inside, you'll see the source program that you can install.

Install with root account.

 

./configure 

make

make install

 

When configuring you may be prompted to give the "--with-apr=..." options.

If apr is not installed, you must install it manually before proceeding.

You can obtain related programs at https://apr.apache.org/.

 

When installing APR, you may get a sock error during the make test phase.
This may be because the port is in use because APR is already installed.
If you shut down Tomcat with shutdown.sh and run make test, it should succeed.

 

Again, I'm going to go back and extract the tomcat-native.tar.gz file.

  /apache-tomcat-8.5.31/bin/tomcat-native-1.2.16-src/native/BUILDING

See the above file for details on how to install it.

 

The following directory names above may vary depending on the downloaded file :

  apache-tomcat-8.5.31

  tomcat-native-1.2.16-src

 

For example, the BUILDING file includes:

3. Build

   > configure  --with-apr=apr_install_location  --with-ssl=openssl_install_location
   > make

   This should produce a file named libtcnative-1.so

   Note: To build without SSL support use:

   > configure  --disable-openssl  --with-apr=apr_install_location

 

(example)

$ ./configure  --with-apr=/usr/local/apr-1.7.5  --with-ssl=/usr/local/ssl-3.3.0  --with-java-home=/usr/lib/jvm/java-21-openjdk-amd64

 

If installed successfully as above,

Libraries have been installed in:
   /usr/local/apr/lib

 

You can see the above statement.

 

The APR library is not interlinked in this state. The message is as follows.

INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]

 

For the APR library to load, you need to add the "java,library.path" of the library to the JAVA environment from Tomcat.


The "java.library.path" configuration can be set by adding the JAVA_OPTS syntax to the catalina.sh file in the Tomcat bin folder as shown below :

# only set CATALINA_HOME if not already set
[ -z "$CATALINA_HOME" ] && CATALINA_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`

# Copy CATALINA_BASE from CATALINA_HOME if not already set
[ -z "$CATALINA_BASE" ] && CATALINA_BASE="$CATALINA_HOME"


JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/usr/local/apr/lib"



After that, when you run the Tomcat, you can see the following message and link the APR library.

INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.0g  2 Nov 2017]

 

 

[Web page referenced]

  https://tomcat.apache.org/tomcat-7.0-doc/apr.html

  https://stackoverflow.com/questions/14018817/how-to-add-a-native-library-in-tomcat

  http://egloos.zum.com/javalove/v/731607

  http://tomcat.10.x6.nabble.com/java-library-path-Unsatisfied-Link-Error-problem-with-Linux-Tomcat-5-5-td2073969.html

Comment

Name               Password 
Content
Check Password.

Please enter your password when registering your comment.