jstack:docker 中的 Windows 上没有安装提供程序

问题描述

我使用基于 microsoft/nanoserver(实际上基于 the jenkins slave image)的 windows Docker 容器。 jstack 无法在此容器中工作,如下所示:

C:\>jstack 39624 
java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider: Provider sun.tools.attach.WindowsAttachProvider Could not be instantiated
39624: no providers installed
The -F option can be used when the target process is not responding

Oracle、OpenJDK 和 Zulu 8 会发生这种情况。

解决方法

docker 容器丢失了 c:\windows\system32\advapi32.dll。从构建主机复制它后,一切正常。

在对 Dependencies 进行一些调查后,这是缺失的部分。我尝试过的每个 JDK 都有一个 jre\bin\attach.dll,大概是由 WindowsAttachProvider 中的代码加载的:

// native functions in this library
static {
    System.loadLibrary("attach");
}

因此在依赖项中加载 attach.dll 给了我可能的罪魁祸首:

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...