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?