【问题标题】:io.netty.handler.ssl.OpenSsl uses tomcat classes instead of selfio.netty.handler.ssl.OpenSsl 使用 tomcat 类而不是 self
【发布时间】:2017-01-28 12:26:06
【问题描述】:

尝试在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试过

【问题讨论】:

    标签: java tomcat netty grpc


    【解决方案1】:

    这将很快得到修复并成为 4.1.9.Final 的一部分:

    https://github.com/netty/netty/pull/5766

    【讨论】:

    • 我只花了 2 天时间。 google-cloud-logging 1.0.2 依赖于 4.1.8 并把我带到了这里。通过 maven 强制 4.1.9+ 解决了它。
    【解决方案2】:

    似乎在这个帖子中找到了解决方案 https://github.com/netty/netty-tcnative/issues/136

    我刚刚复制了 netty-tcnative-boringssl-static.jar 并将 tomcat-jni.jar 重新链接到 tomcat 库目录中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-05
      • 1970-01-01
      • 1970-01-01
      • 2013-11-25
      • 2010-11-08
      • 1970-01-01
      • 1970-01-01
      • 2018-05-21
      相关资源
      最近更新 更多