試圖在tomcat下使用netty-tcnative-boringssl-static。從JUnit執行代碼測試時,它可以正常工作,但在tomcat容器中不是這樣。 io.netty.handler.ssl.OpenSsl類中的此代碼嘗試從SSL類的類加載器加載本地庫。io.netty.handler.ssl.OpenSsl使用tomcat類代替自己
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測試)這是找到SSL類網狀-tcnative-boringssl靜態罐子,從WEB-INF /在那些罐子依賴本地獲得本機庫從它。 但是,當它在tomcat下工作時,它從tomcat庫獲取SSL類並找不到本機庫。
試圖與Tomcat的8和9
我剛在這上面花了2天時間。 谷歌雲端日誌記錄1.0.2依賴於4.1.8,並把我帶到這裏。 通過maven強制4.1.9+解決了它。 – Nadav