Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Tomcat logs that the native library for OpenSSL was not found

ErrorThe Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path

Short answer

This line is a notice, not a crash. Tomcat looks for the optional Tomcat Native library to use OpenSSL for TLS, and when it is missing it falls back to the JVM's own TLS (JSSE). If you want OpenSSL, build or install libtcnative, put it on the library path, and keep the AprLifecycleListener in server.xml.

  • Applies to Tomcat 10.1, Tomcat 11, Tomcat Native 2.x, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look in catalina.out (or the service journal) for the startup lines about the native library. A working setup prints a 'Loaded Apache Tomcat Native library' line and an OpenSSL initialised line.

    grep -n -i -E 'native library|openssl' $CATALINA_BASE/logs/catalina.out
  2. 2Match what you see, then jump to its fix

    1. 1The 'was not found' message and nothing about a loaded libraryThe native library was never installedFix
    2. 2libtcnative is on disk, yet the message still appearsThe library exists but the JVM cannot find itFix
    3. 3The library is installed and on the path, but nothing is loaded at startupThe listener that loads the library is missing from server.xmlFix
    4. 4HTTPS already works and only the message bothers youYou do not need OpenSSL at allFix

What does the error look like?

  • The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path

Cause 1 of 4

The native library was never installed

1Check

Tomcat Native is optional and is not part of the Tomcat download. Look for the library file in Tomcat's lib folder or the system library folders.

find $CATALINA_HOME/lib /usr/lib /usr/local -name 'libtcnative*' 2>/dev/null

2Fix

Install what is needed to build it (the APR library, OpenSSL libraries and a JDK), then build it from the Tomcat Native source distribution. The libraries are installed into $CATALINA_HOME/lib.

sudo apt-get install libapr1-dev libssl-dev
# inside the native/ folder of the tomcat-native source
./configure --with-java-home=$JAVA_HOME --prefix=$CATALINA_HOME
make && make install

3Verify

Restart Tomcat and read the startup lines again.

$CATALINA_HOME/bin/shutdown.sh; $CATALINA_HOME/bin/startup.sh
grep -n -i 'native library' $CATALINA_BASE/logs/catalina.out

Confirmed by tomcat.apache.org

Did this fix it?

Cause 2 of 4

The library exists but the JVM cannot find it

1Check

The JVM only searches its library path. On Linux the build puts the files in $CATALINA_HOME/lib, which is not on it unless you add it.

echo $LD_LIBRARY_PATH

2Fix

Add the folder to the library path in $CATALINA_HOME/bin/setenv.sh, so every start picks it up.

# $CATALINA_HOME/bin/setenv.sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib

3Verify

Restart and look for the 'Loaded Apache Tomcat Native library' line.

grep -n 'Loaded Apache Tomcat Native' $CATALINA_BASE/logs/catalina.out

Confirmed by tomcat.apache.org

Did this fix it?

Cause 3 of 4

The listener that loads the library is missing from server.xml

1Check

Tomcat loads the native library through AprLifecycleListener. It is enabled by default, but an edited server.xml may have lost it or commented it out.

grep -n 'AprLifecycleListener' $CATALINA_BASE/conf/server.xml

2Fix

Make sure this line is present and not commented out.

<Listener className="org.apache.catalina.core.AprLifecycleListener" />

3Verify

Restart and check the startup log.

grep -n -i openssl $CATALINA_BASE/logs/catalina.out

Confirmed by tomcat.apache.org

Did this fix it?

Cause 4 of 4

You do not need OpenSSL at all

1Check

Without the native library the connector uses org.apache.tomcat.util.net.jsse.JSSEImplementation, which wraps the JVM's own TLS. That is a supported, working setup.

curl -vkI https://localhost:8443 2>&1 | grep -i -E 'SSL connection|TLS'

2Fix

Leave things as they are. Note that if you do install the native library, the connectors switch to OpenSSL by default, so retest your certificates (use either Java keystore attributes or PEM attributes on a connector, not both).

# nothing to change; to name the implementation explicitly
# <Connector ... sslImplementationName="org.apache.tomcat.util.net.jsse.JSSEImplementation">

3Verify

HTTPS answers on the connector port.

curl -kI https://localhost:8443

Confirmed by tomcat.apache.org

Did this fix it?

How do I stop it coming back?

  • Decide once whether the server uses JSSE or OpenSSL, and write it in your setup notes.
  • Put the library path in setenv.sh and not in a login shell profile, which a service manager does not read.
  • After a Tomcat or JDK upgrade, check the startup log for this line and the 'Loaded' line.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.