我们正在使用 YAJSW 将我们的 Java 应用程序包装为 Windows 服务。在测试工作站映像时,公司 McAfee Antivirus 会发出警告,因为在启动服务时,jnidispatch.dll 会从 jna-4.1.0.jar 复制到临时文件夹中的新名称。
将 dll 签名添加到防病毒规则可防止显示停止错误,但每次都会弹出严重警告。
我们尝试将 jnidispath.dll 复制到 C:\DLLfolder 并添加到 wrapper.conf 行:
wrapper.java.additional.4 = -Djna.boot.library.path=C:/DLLfolder/
然后我们将 C:\DLLfolder 添加到 Windows 系统 %PATH% 并重新启动 Windows。
但是,当监控 Windows 服务启动时,我们仍然可以看到 DLL 被从 Jar 中提取出来,并且防病毒软件会报错。
YAJSW 代码 native.java 中的注释说:
When JNA classes are loaded, the native shared library (jnidispatch) is
loaded as well. An attempt is made to load it from the any paths defined
in <code>jna.boot.library.path</code> (if defined), then the system library
path using {@link System#loadLibrary}, unless <code>jna.nosys=true</code>.
If not found, the appropriate library will be extracted from the class path
(into a temporary directory if found within a jar file) and loaded from
there, unless <code>jna.noclasspath=true</code>.
我们缺少哪一步?