【发布时间】: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目录?
【问题讨论】: