最近转行做java,开发基于Springboot的项目,版本号为2.1.0.RELEASE.

启动应用,发现以下提示:

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]

提示告知,使用基于Apache Tomcat Native libraryARP可以提升生产环境性能.

以下是从网上节选的话语:

apr是从操作系统级别解决异步IO问题,大幅度提高服务器的并发处理性能,也是Tomcat生产环境运行的首选方式.

目前Tomcat 8.x默认情况下全部是运行在nio模式下,而apr的本质就是使用jni技术调用操作系统底层的IO接口.

如此具有诱惑力,当然值得花费时间去解决,按照网上教程安装依赖:

sudo apt-get isntall libapr1-dev libssl-dev libtcnative-1

此处,需要注意网上给出的资源大多数是libapr以及libtcnative,安装时提示无法找到.

因此,搜索到包名被修改成上述定义.

$ dpkg -L libtcnative-1

# 以下是输出信息
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libtcnative-1.a
/usr/lib/x86_64-linux-gnu/libtcnative-1.so.0.2.16
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/tcnative-1.pc
/usr/share
/usr/share/doc
/usr/share/doc/libtcnative-1
/usr/share/doc/libtcnative-1/README.Debian
/usr/share/doc/libtcnative-1/changelog.Debian.gz
/usr/share/doc/libtcnative-1/changelog.gz
/usr/share/doc/libtcnative-1/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libtcnative-1
/usr/lib/x86_64-linux-gnu/libtcnative-1.so
/usr/lib/x86_64-linux-gnu/libtcnative-1.so.0

使用dpkg可以得知,libtcnative-1的静态库被安装至:/usr/lib/x86_64-linux-gnu.

因此,启动程序:

java -jar -Djava.library.path=/usr/lib/x86_64-linux-gnu cache-0.0.1-SNAPSHOT.jar
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE) org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2019-01-10 15:33:55.586 INFO 2243 --- [ main] o.a.catalina.core.AprLifecycleListener : An older version [1.2.16] of the APR based Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [1.2.18]
2019-01-10 15:33:55.586 INFO 2243 --- [ main] o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
2019-01-10 15:33:55.586 INFO 2243 --- [ main] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-01-10 15:33:55.586 INFO 2243 --- [ main] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-01-10 15:33:55.597 INFO 2243 --- [ main] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.0h 27 Mar 2018]
2019-01-10 15:33:55.748 INFO 2243 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext

输出的启动信息中,可以看到APR based Apache Tomcat Native library被加载了.

但是让人心塞的是,输出信息中提示版本过低,不满足现阶段使用的最小版本要求(差了两个小版本号).

An older version [1.2.16] of the APR based Apache Tomcat Native library is installed, while Tomcat recommends a minimum version of [1.2.18]

根据网上搜索结果可知,无法通过apt-get去安装高版本的libtcnative,只能手动编译安装.

因此,去Tomcat官网下载(http://tomcat.apache.org/native-doc/),可以看到最新的版本号为1.2.19,于是下载源码包.

解压后可以看到目录结构:

.
├── build.properties.default
├── build.xml
├── CHANGELOG.txt
├── CMakeLists.txt
├── docs
├── examples
├── java
├── jnirelease.sh
├── LICENSE
├── native
├── NOTICE
├── README.txt
├── test
├── TODO.txt
└── xdocs

执行以下命令,进行编译安装:

sudo apt-get autoremove libtcnative-1 #删除安装的库
cd native
./configure && make -j 4
sudo make install

此处,configure命令无需按照官网指示配置参数,会自行搜索依赖所在路径.

安装完之后,可以得知静态库被安装至/usr/local/apr/lib.

重新启动程序:

java -jar -Djava.library.path=/usr/local/apr/lib cache-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE) o.a.catalina.core.AprLifecycleListener : Loaded APR based Apache Tomcat Native library [1.2.19] using APR version [1.6.3].
2019-01-10 15:48:29.130 INFO 7538 --- [ main] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2019-01-10 15:48:29.130 INFO 7538 --- [ main] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2019-01-10 15:48:29.136 INFO 7538 --- [ main] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.0h 27 Mar 2018]
2019-01-10 15:48:29.255 INFO 7538 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext

通过输出信息,可以得知:程序完美加载APR based Apache Tomcat Native library,性能就等着提升了.

将参数设置到ideaVM options中,调试的时候也舒服了许多.

PS:

如果您觉得我的文章对您有帮助,可以扫码领取下红包,谢谢!

Linux下Springboot解决`APR based Apache Tomcat Native library`提示的更多相关文章

  1. The APR based Apache Tomcat Native library 异常解决办法

    tomat在linux服务器上启动报The APR based Apache Tomcat Native library which allows optimal performance in pro ...

  2. 【问题解决:信息提示】SpringBoot启动时提示The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path

    问题描述 springboot程序在启动时提示信息 [2018-10-24 21:59:05.214] - 440 信息 [restartedMain] --- org.apache.catalina ...

  3. 解决:The APR based Apache Tomcat Native library which allows optimal performance in production...

    tomcat日志apr报错引发的基于Tomcat Native加速Tomcat性能 tomact服务启动报错日志如下:息: The APR based Apache Tomcat Native lib ...

  4. springboot An incompatible version [1.1.32] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]

    1.错误 An incompatible version [1.1.32] of the APR based Apache Tomcat Native library is installed, wh ...

  5. 关于Tomcat启动时报The APR based Apache Tomcat Native library which allows optimal performanc e in production environments was not found on the java.library.path

    错误信息如下 八月 01, 2016 10:11:15 上午 org.apache.catalina.core.AprLifecycleListener initINFO: The APR based ...

  6. 关于The APR based Apache Tomcat Native library警告

    今天在Eclipse上配置Tomcat7,启动时看到如下警告信息: The APR based Apache Tomcat Native library which allows optimal pe ...

  7. An incompatible version [1.1.29] of the APR based Apache Tomcat Native library is installed, while Tomcat requires version [1.2.14]

    问题描述   首先,这是一个提示信息而不是报错,并不影响 Tomcat 的使用.它是建议你使用一个 Tomcat 的性能调优原生库文件 tcnative-1.dll   几天前,我想尝试一下 Apac ...

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

    运行环境: Intellij idea 14 在改了项目名称. 运行时候出现了 The APR based Apache Tomcat Native library which allows opti ...

  9. IDEA搭建ssm框架测试衍生出的问题The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Develop\jdk7\jdk1.7.0_79\bin;

    最近玩起IDEA这开发工具,搭建ssm框架测试时,部署项目出现如下问题: 信息: The APR based Apache Tomcat Native library which allows opt ...

随机推荐

  1. 两种方法轻松搞定-- Eclipse 安装FindBugs插件

    1安装:首先到官方网站下载最新版本FindBugs    http://findbugs.sourceforge.net/downloads.html              将 edu.umd.c ...

  2. 如何解决python升级后yum报错

    当我们yum命令的时候,会提示 "File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxEr ...

  3. Firefox Profile (2)

    一些关于selenium copy Firefox profile to a temp directory的讨论 https://stackoverflow.com/questions/6787095 ...

  4. Oracle 重建控制文件一例

    环境:OEL 5.7 + Oracle 10.2.0.5 背景:在Oracle的运维过程中,时常会遇到一些场景是需要重建控制文件才可以解决的.本文的场景可以通过复制控制文件到新路径,运行一段时间后,再 ...

  5. java 中 一个int类型的num,num&1

    n&1 把n与1按位与,因为1除了最低位,其他位都为0,所以按位与结果取决于n最后一位,如果n最后一位是1,则结果为1.反之结果为0.(n&1)==1: 判断n最后一位是不是1(可能用 ...

  6. Go-技篇第一 技巧杂烩

    Go-技篇第一 技巧杂烩 一句话技巧 把你面向对象的大脑扔到家里吧,去拥抱接口.@mikegehard 学习如何使用Go的方式做事,不要把别的的编程风格强行用在Go里面.@DrNic 多用接口总比少用 ...

  7. Windows上安装配置SSH教程(1)——知识点汇总

    1.是什么SSH? 维基百科:https://zh.wikipedia.org/wiki/Secure_Shell 其他博客:http://www.ruanyifeng.com/blog/2011/1 ...

  8. Sublime text3所遇到的问题

    sublime text3的下载地址:https://www.sublimetext.com/ 解决sublime text上不能使用交互的input的输入问题 通过安装sublimeREPL插件解决 ...

  9. CentOS7搭建本地YUM仓库,并定期同步阿里云源

    CentOS7同步阿里云镜像rpm包并自建本地yum仓库 系统环境 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # u ...

  10. eShopOnContainers 知多少[8]:Ordering microservice

    1. 引言 Ordering microservice(订单微服务)就是处理订单的了,它与前面讲到的几个微服务相比要复杂的多.主要涉及以下业务逻辑: 订单的创建.取消.支付.发货 库存的扣减 2. 架 ...