简体   繁体   中英

Configuring Glowroot with tomcat temp folder locked shows following exception

I am configuring Glowroot agent on client Tomcat, for security reasons we only provide read access to Tomcat's temp directory, glowroot -> tcnative -> netty use to create a temp file in Tomcat temp dir and delete it after successful execution, but as we kept limited access to temp folder, I got this exception. If I provide rwx access to Tomcat temp folder everything works fine.

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)

As per documentation we can set netty tmp directory by vm argument -Dio.netty.native.workdir=/some/dir But this does not honor while runtime it jumps back to tomcat temp as per the code in io.netty.util.internal.PlatformDependent

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;
}

How to force set Netty tmp directory?

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

Netty use to look for libraries beforehand in the jre libs so in normal case if dll is made available inside jre/libs/ with the name specified below, It will be loaded

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

or

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

check for your os.name and os.arch to replace the last suffix in lib name

If the netty services are used as uber jar, check for the shaded package name to be appended, for glowroot this will be org_glowroot_agent_shaded_netty_tcnative_windows_x86_64.dll

*for version above windows 8.1 os.name might not work as expected, refer Java's "os.name" for Windows 10?

For finding os.name and os.arch execute below code

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM