“找不到基于 APR 的 Apache Tomcat 本机库”是什么意思?意思是?

发布于 2024-12-24 18:38:25 字数 201 浏览 4 评论 0原文

我在 Windows 上的 Eclipse 中使用 Tomcat 7。启动 Tomcat 时,我收到以下信息消息:

在 java.library.path 上找不到基于 APR 的 Apache Tomcat Native 库,该库可在生产环境中提供最佳性能

这是什么意思以及如何提供 APR 库?

I am using Tomcat 7 in Eclipse on Windows. When starting Tomcat, I am getting the following info message:

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

What does this mean and how can I provide the APR library?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

许你一世情深 2024-12-31 18:38:25

它的意思正是它所说的:“在 java.library.path 上找不到基于 APR 的 Apache Tomcat Native 库,它可以在生产环境中提供最佳性能”。

引用的库被捆绑到特定于操作系统的操作系统中。通过 JNI 加载 dll (tcnative-1.dll)。它允许tomcat使用Java运行时中未提供的操作系统功能(例如sendfile、epoll、OpenSSL、系统状态等)。如果没有它,Tomcat 也能正常运行,但对于某些用例,使用本机库会更快。

如果您确实需要,请下载 tcnative-1.dll(或libtcnative.so for Linux)并将其放入bin文件夹中,并在eclipse中将系统属性添加到tomcat服务器的启动配置中。

 -Djava.library.path=c:\dev\tomcat\bin

It means exactly what it says: "The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path"

The library referred to is bundled into an OS specific dll (tcnative-1.dll) loaded via JNI. It allows tomcat to use OS functionalities not provided in the Java Runtime (such as sendfile, epoll, OpenSSL, system status, etc.). Tomcat will run just fine without it, but for some use cases, it will be faster with the native libraries.

If you really want it, download the tcnative-1.dll (or libtcnative.so for Linux) and put it in the bin folder, and add a system property to the launch configuration of the tomcat server in eclipse.

 -Djava.library.path=c:\dev\tomcat\bin
安静被遗忘 2024-12-31 18:38:25

除非您正在运行生产服务器,否则不必担心此消息。这是一个用于提高性能(在生产系统上)的库。来自 基于 Apache 可移植运行时 (APR) 的 Tomcat 本机库

Tomcat 可以使用 Apache Portable Runtime 来提供卓越的性能
可扩展性、性能以及与本机服务器更好的集成
技术。 Apache Portable Runtime 是一个高度可移植的库
这是 Apache HTTP Server 2.x 的核心。 APR有很多用途,
包括访问高级 IO 功能(例如 sendfile、epoll
和 OpenSSL)、操作系统级功能(随机数生成、系统
状态等)和本机进程处理(共享内存、NT 管道和
Unix 套接字)。

Unless you're running a production server, don't worry about this message. This is a library which is used to improve performance (on production systems). From Apache Portable Runtime (APR) based Native library for Tomcat:

Tomcat can use the Apache Portable Runtime to provide superior
scalability, performance, and better integration with native server
technologies. The Apache Portable Runtime is a highly portable library
that is at the heart of Apache HTTP Server 2.x. APR has many uses,
including access to advanced IO functionality (such as sendfile, epoll
and OpenSSL), OS level functionality (random number generation, system
status, etc), and native process handling (shared memory, NT pipes and
Unix sockets).

情痴 2024-12-31 18:38:25

在 RHEL Linux 上只需发出:

yum install tomcat-native.x86_64

/注意:根据您的架构,64 位或 32 位软件包可能有不同的扩展名/

仅此而已。之后,您将在日志文件中找到下一条信息消息:

INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

所有操作将明显比以前更快。

On RHEL Linux just issue:

yum install tomcat-native.x86_64

/Note:depending on Your architecture 64bit or 32bit package may have different extension/

That is all. After that You will find in the log file next informational message:

INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

All operations will be noticeably faster than before.

时常饿 2024-12-31 18:38:25

在 Ubuntu 服务器上安装本机库:

sudo apt-get install libtcnative-1

如果这不起作用,则需要安装 tomcat-native

  1. 安装 Oracle java7:

    • sudo add-apt-repository ppa:webupd8team/java
    • sudo apt-get update
    • sudo apt-get install oracle-java7-installer
    • sudo apt-get install oracle-java7-set-default
  2. 安装tomcat apr:

  3. 安装 tomcat tomcat-native:

    • wget

Installation the native library on Ubuntu server with:

sudo apt-get install libtcnative-1

If that does not work tomcat-native needs to be installed

  1. Install Oracle java7:

    • sudo add-apt-repository ppa:webupd8team/java
    • sudo apt-get update
    • sudo apt-get install oracle-java7-installer
    • sudo apt-get install oracle-java7-set-default
  2. Install tomcat apr:

  3. Install tomcat tomcat-native:

咿呀咿呀哟 2024-12-31 18:38:25

我刚刚完成此操作并使用以下内容进行配置:

Ubuntu 16.04

Tomcat 8.5.9

Apache2.4.25

APR 1.5.2

Tomcat-native 1.2.10

Java 8

这些是我根据此处的旧帖子使用的步骤:

安装包

sudo apt-get update
sudo apt-get install libtcnative-1

验证这些安装软件包

sudo apt-get install make 
sudo apt-get install gcc
sudo apt-get install openssl

安装软件包

sudo apt-get install libssl-dev

安装并编译 Apache APR

cd /opt/tomcat/bin
sudo wget http://apache.mirror.anlx.net//apr/apr-1.5.2.tar.gz
sudo tar -xzvf apr-1.5.2.tar.gz
cd apr-1.5.2
sudo ./configure
sudo make
sudo make install

验证安装,

cd /usr/local/apr/lib/
ls 

您应该看到编译后的文件为

libapr-1.la

下载并安装 Tomcat Native 源码包

cd /opt/tomcat/bin
sudo wget https://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.2.10/source/tomcat-native-1.2.10-src.tar.gz
sudo tar -xzvf tomcat-native-1.2.10-src.tar.gz
cd tomcat-native-1.2.10-src/native

验证 JAVA_HOME

sudo pico ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
source ~/.bashrc
sudo ./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME
sudo make
sudo make install

编辑 /opt/tomcat/bin/setenv.sh 文件,添加以下行:

sudo pico /opt/tomcat/bin/setenv.sh
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'

restart tomcat

sudo service tomcat restart

I just went through this and configured it with the following:

Ubuntu 16.04

Tomcat 8.5.9

Apache2.4.25

APR 1.5.2

Tomcat-native 1.2.10

Java 8

These are the steps i used based on the older posts here:

Install package

sudo apt-get update
sudo apt-get install libtcnative-1

Verify these packages are installed

sudo apt-get install make 
sudo apt-get install gcc
sudo apt-get install openssl

Install package

sudo apt-get install libssl-dev

Install and compile Apache APR

cd /opt/tomcat/bin
sudo wget http://apache.mirror.anlx.net//apr/apr-1.5.2.tar.gz
sudo tar -xzvf apr-1.5.2.tar.gz
cd apr-1.5.2
sudo ./configure
sudo make
sudo make install

verify installation

cd /usr/local/apr/lib/
ls 

you should see the compiled file as

libapr-1.la

Download and install Tomcat Native source package

cd /opt/tomcat/bin
sudo wget https://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.2.10/source/tomcat-native-1.2.10-src.tar.gz
sudo tar -xzvf tomcat-native-1.2.10-src.tar.gz
cd tomcat-native-1.2.10-src/native

verify JAVA_HOME

sudo pico ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
source ~/.bashrc
sudo ./configure --with-apr=/usr/local/apr --with-java-home=$JAVA_HOME
sudo make
sudo make install

Edit the /opt/tomcat/bin/setenv.sh file with following line:

sudo pico /opt/tomcat/bin/setenv.sh
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/apr/lib'

restart tomcat

sudo service tomcat restart

对你而言 2024-12-31 18:38:25

在 Mac OS X 上:

$ brew install tomcat-native
==> tomcat-native
In order for tomcat's APR lifecycle listener to find this library, you'll
need to add it to java.library.path. This can be done by adding this line
to $CATALINA_HOME/bin/setenv.sh

  CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/opt/tomcat-native/lib"

If $CATALINA_HOME/bin/setenv.sh doesn't exist, create it and make it executable.

然后将其添加到 eclipse 的 tomcat 参数中(双击服务器 > 打开启动配置 > 参数选项卡 > VM 参数)

-Djava.library.path=/usr/local/opt/tomcat-native/lib

On Mac OS X:

$ brew install tomcat-native
==> tomcat-native
In order for tomcat's APR lifecycle listener to find this library, you'll
need to add it to java.library.path. This can be done by adding this line
to $CATALINA_HOME/bin/setenv.sh

  CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/opt/tomcat-native/lib"

If $CATALINA_HOME/bin/setenv.sh doesn't exist, create it and make it executable.

Then add it to the eclipse's tomcat arguments (double-click Server > Open Launch Configuration > Arguments tab > VM arguments)

-Djava.library.path=/usr/local/opt/tomcat-native/lib
猫烠⑼条掵仅有一顆心 2024-12-31 18:38:25

在 debian 8 上,我通过安装 libapr1-dev 来修复它:

apt-get install libtcnative-1 libapr1-dev

on debian 8 I fix it with installing libapr1-dev:

apt-get install libtcnative-1 libapr1-dev
緦唸λ蓇 2024-12-31 18:38:25

也遇到了这个问题。如果您确实拥有这些库,但仍然出现此错误,则可能是配置错误。您的 server.xml 可能缺少以下行:(

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

或者,它可能被注释掉)。与其他侦听器一样,此 是顶级 的子级。

如果没有 行,则不会尝试加载 APR 库,因此 LD_LIBRARY_PATH-Djava.library.path= 设置为被忽略。

Had this problem as well. If you do have the libraries, but still have this error, it may be a configuration error. Your server.xml may be missing the following line:

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

(Alternatively, it may be commented out). This <Listener>, like other listeners is a child of the top-level <Server>.

Without the <Listener> line, there's no attempt to load the APR library, so LD_LIBRARY_PATH and -Djava.library.path= settings are ignored.

不一样的天空 2024-12-31 18:38:25

从 Java 8 升级到 11 时遇到了这个问题。添加此依赖项后,我的应用程序启动没有问题:

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.25.0-GA</version>
</dependency>

I had this issue upgrading from Java 8 to 11. After adding this dependency, my app launched without issue:

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.25.0-GA</version>
</dependency>
剩一世无双 2024-12-31 18:38:25

对于未来的读者:
当我尝试在 Spring STS 中运行 Spring Boot 应用程序时,我自己也遇到过这个问题。这个问题最初并没有再次出现。我能够在相当长的一段时间内毫无问题地处理我的项目,直到有一天我开始遇到这个特殊的错误。

据我所知,我没有对我的项目进行任何配置更改,也没有更改正在使用的 Java/Tomcat 版本。

关于安装 tomcat 本机库的讨论/建议对我来说没有任何意义,因为该项目之前已经运行良好。

对我有用的解决方案:

所以最后我想尝试删除并重新导入我的项目。

我从 Spring STS 中删除我的项目,重新启动 Spring STS,然后重新导入该项目。它就像一个魅力,从那以后就再也没有遇到过这个问题。

在重新启动 IDE 并重新导入项目之前,您还可以尝试删除项目中任何 IDE 生成的文件/文件夹(如果有)。

我仍然时不时地参与这个项目,但到目前为止还没有遇到这个问题。我目前的开发IDE是IntelliJ。

我不确定该错误是否是 IDE 特定的。

For future readers:
I had faced this issue myself when trying to run a Spring Boot application in Spring STS. This issue didn't resurface initially. I was able to work on my project without any issues for quite some time until one fine day I started getting this particular error.

From what I am able to recall I had not made any configuration changes to my project and neither changed the Java/Tomcat version being used.

None of the discussions/suggestions regarding installing the tomcat native library made any sense to me since the project was already working fine before.

SOLUTION that worked for me:

So lastly I though of trying to delete and reimport my project.

I deleted my project from Spring STS, restarted the Spring STS and then reimported the project. It worked like a charm and never faced the issue ever since.

You may also try deleting any IDE generated files/folders(if there are any) in your project, before restarting the IDE and reimporting the project.

I still happen to work on this project from time to time and haven't faced the issue as of now. My current development IDE is IntelliJ.

I'm not sure if the error was IDE specific.

浅笑轻吟梦一曲 2024-12-31 18:38:25

当 tomсat 找不到该课程时,我遇到了同样的问题。尝试查看其他日志文件。有时,不同的日志文件中会出现“找不到类定义”错误:

  • tomcat8-stdout
  • tomcat8-stderr
  • localhost

I had the same problem when tomсat could not find the class. Try to view other log files. Sometimes No class def found error appears in different log files:

  • tomcat8-stdout
  • tomcat8-stderr
  • localhost
今天小雨转甜 2024-12-31 18:38:25

如果您没有 Tomcat Native 库,请使用以下命令安装它:

sudo apt-get install libtcnative-1

如果仍然存在旧版本,请使用以下命令进行升级:

sudo apt-get 升级 libtcnative-1

If you don't have Tomcat Native library install it with:

sudo apt-get install libtcnative-1

and if it's still there an old version upgrade it with:

sudo apt-get upgrade libtcnative-1

两个我 2024-12-31 18:38:25

我的问题是从 tomcat 添加一些库到 eclipse 类路径,我只是要
eclipse 单击右键进入项目并转到调试配置 ->类路径->添加外部 JAR 添加来自 apache-tomcat-7.0.35\bin 的所有 jar 文件,这是我的问题,它对我有用。
输入图片此处描述

My problem was in add some library from tomcat to eclipse class path i just going to
eclipse click right to project and going to debug configuration -> classpath -> Add External JARs add all jars files from apache-tomcat-7.0.35\bin this was my problem and it's worked for me .
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文