尝试在tomcat下使用netty-tcnative-boringssl-static。当午餐来自JUnit测试的代码时,它可以正常工作,但在tomcat容器中却无法正常工作。
io.netty.handler.ssl.OpenSsl类中的此代码正尝试从SSL类的类加载器加载本机库。
private static void loadTcNative() throws Exception {
String os = normalizeOs(SystemPropertyUtil.get("os.name", ""));
String arch = normalizeArch(SystemPropertyUtil.get("os.arch", ""));
Set<String> libNames = new LinkedHashSet<String>(3);
// First, try loading the platform-specific library. Platform-specific
// libraries will be available if using a tcnative uber jar.
libNames.add("netty-tcnative-" + os + '-' + arch);
if (LINUX.equalsIgnoreCase(os)) {
// Fedora SSL lib so naming (libssl.so.10 vs libssl.so.1.0.0)..
libNames.add("netty-tcnative-" + os + '-' + arch + "-fedora");
}
// finally the default library.
libNames.add("netty-tcnative");
NativeLibraryLoader.loadFirstAvailable(SSL.class.getClassLoader(),
libNames.toArray(new String[libNames.size()]));
}
当它单独工作时(例如从JUnit测试中),它将在netty-tcnative-boringssl-static jar中找到SSL类,并从这些jar依赖项的WEB-INF / native中获取本地库。
但是,当它在tomcat下工作时,它会从tomcat库获取SSL类,并且找不到本地库。
尝试过tomcat 8和9
最佳答案
这将很快得到修复,并将成为4.1.9.Final的一部分:
https://github.com/netty/netty/pull/5766