【问题标题】:Configuring Glowroot with tomcat temp folder locked shows following exception在 tomcat 临时文件夹锁定的情况下配置 Glowroot 显示以下异常
【发布时间】:2019-08-22 11:08:24
【问题描述】:

我正在客户端 Tomcat 上配置 Glowroot 代理,出于安全原因,我们只提供对 Tomcat 临时目录的读取访问权限,glowroot -> tcnative -> netty 用于在 Tomcat 临时目录中创建临时文件和成功执行后将其删除,但由于我们对临时文件夹的访问权限有限,因此出现此异常。如果我提供rwx 对 Tomcat 临时文件夹的访问权限,一切正常。

java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available
    at org.glowroot.agent.shaded.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:258)
    at org.glowroot.agent.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
    at org.glowroot.agent.shaded.io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:120)
    at org.glowroot.agent.central.CentralConnection.<init>(CentralConnection.java:125)
    at org.glowroot.agent.central.CentralCollector.<init>(CentralCollector.java:135)
    at org.glowroot.agent.init.NonEmbeddedGlowrootAgentInit$1.run(NonEmbeddedGlowrootAgentInit.java:136)
    at org.glowroot.agent.impl.BytecodeServiceImpl.enteringMainMethod(BytecodeServiceImpl.java:255)
    at org.glowroot.agent.impl.BytecodeServiceImpl.enteringMainMethod(BytecodeServiceImpl.java:77)
    at org.glowroot.agent.bytecode.api.Bytecode.enteringMainMethod(Bytecode.java:32)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java)

根据文档,我们可以通过 vm 参数设置 netty tmp 目录 -Dio.netty.native.workdir=/some/dir 但这并不符合运行时它根据io.netty.util.internal.PlatformDependent中的代码跳回tomcat temp的情况@

private static File tmpdir0() {
    File f;
    try {
        f = toDirectory(SystemPropertyUtil.get("io.netty.tmpdir"));
        if (f != null) {
            logger.debug("-Dio.netty.tmpdir: {}", f);
            return f;
        }

        f = toDirectory(SystemPropertyUtil.get("java.io.tmpdir"));
        if (f != null) {
            logger.debug("-Dio.netty.tmpdir: {} (java.io.tmpdir)", f);
            return f;
        }

        // This shouldn't happen, but just in case ..
        if (isWindows()) {
            f = toDirectory(System.getenv("TEMP"));
            if (f != null) {
                logger.debug("-Dio.netty.tmpdir: {} (%TEMP%)", f);
                return f;
            }

            String userprofile = System.getenv("USERPROFILE");
            if (userprofile != null) {
                f = toDirectory(userprofile + "\\AppData\\Local\\Temp");
                if (f != null) {
                    logger.debug("-Dio.netty.tmpdir: {} (%USERPROFILE%\\AppData\\Local\\Temp)", f);
                    return f;
                }

                f = toDirectory(userprofile + "\\Local Settings\\Temp");
                if (f != null) {
                    logger.debug("-Dio.netty.tmpdir: {} (%USERPROFILE%\\Local Settings\\Temp)", f);
                    return f;
                }
            }
        } else {
            f = toDirectory(System.getenv("TMPDIR"));
            if (f != null) {
                logger.debug("-Dio.netty.tmpdir: {} ($TMPDIR)", f);
                return f;
            }
        }
    } catch (Throwable ignored) {
        // Environment variable inaccessible
    }

    // Last resort.
    if (isWindows()) {
        f = new File("C:\\Windows\\Temp");
    } else {
        f = new File("/tmp");
    }

    logger.warn("Failed to get the temporary directory; falling back to: {}", f);
    return f;
}

如何强制设置Netty tmp目录?

【问题讨论】:

    标签: java netty grpc


    【解决方案1】:

    试试这个 vm 参数-Dorg.glowroot.agent.shaded.io.netty.tmpdir="your\path"

    【讨论】:

      【解决方案2】:

      Netty 用于预先在 jre 库中查找库,因此在正常情况下,如果在 jre/libs/ 中提供了以下指定名称的 dll,它将被加载

      "netty_tcnative_[os.name]_[os.arch].dll"(windows)
      

      "netty_tcnative_[os.name]_[os.arch].so"(linux)
      

      检查您的 os.name 和 os.arch 以替换 lib 名称中的最后一个后缀

      如果 netty 服务用作 uber jar,请检查要附加的阴影包名称,对于 gloomroot,这将是 org_glowroot_agent_shaded_netty_tcnative_windows_x86_64.dll

      *对于 windows 8.1 以上版本,os.name 可能无法按预期工作,请参阅Java's "os.name" for Windows 10?

      用于查找 os.name 和 os.arch 执行以下代码

      SystemPropertyUtil.get("os.name")
      SystemPropertyUtil.get("os.arch")
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-09
        • 1970-01-01
        相关资源
        最近更新 更多