leadtools.RasterException: 本机库 Ltkrnx.dll 已经加载到另一个类加载器中

leadtools.RasterException: Native Library Ltkrnx.dll already loaded in another classloader

我遇到的问题:

本机库Ltkrnx.dll已经加载到另一个类加载器

重新部署应用程序期间(tomcat 8 服务器)。

我也添加了检查,但这对我没有帮助。

private void loadLibrary(LTLibrary library) {
    if (!Platform.isLibraryLoaded(library)) {
        Platform.loadLibrary(library);
    }
}

原因:leadtools.RasterException:本机库 C:\LEADTOOLS 20\Bin\CDLL\x64\Ltkrnx.dll 已加载到另一个类加载器中

您是否在 2 个不同的 Web 应用程序中使用 LEADTOOLS?如果是,以下答案可能会帮助您解决问题:

由于该问题是关于 OpenCV,而不是 LEADTOOLS,因此我将在此处引用相关部分(略微编辑):

Now there's the restriction that a native library can only be loaded in one class loader. Web applications use their own class loader so if one web application has loaded a native library, another web application cannot do the same. Therefore code loading native libraries cannot be put in a webapp directory but must be put in the container's (Tomcat) shared directory. When you have a class written with the usual pattern above (loadLibrary in static initializer of using class) it's enough to put the jar containing the class in the shared directory. With .. the loadLibrary call in the web application code however, the native library will still be loaded in the "wrong" class loader and you will get the UnsatisfiedLinkError.

To make the "right" class loader load the native library you could create a tiny class with a single static method doing only the loadLibrary. Put this class in an extra jar and put this jar in the shared Tomcat directory. Then in the web applications replace the call to System.loadLibrary with a call to your new static method. This way the class loaders for the .. native library will match and the native methods can be initialized.

如果您的情况不同,或者那里的建议对您没有帮助,请将以下信息发送至支持@leadtools.com,我们的支持团队将与您一起解决问题:

  1. 此问题的详细信息(您遇到的异常,LEADTOOLS 版本 20,64 位,Tomcat 8)
  2. 您的 LEADTOOLS 产品序列号(不要 post 这里!)。如果您仍在评估并且没有序列号,请提出来。
  3. 到目前为止您为解决问题所做的尝试以及给您的结果是什么(例如,上面提到的答案)。
  4. 关于您的 OS、IDE 或一般编程环境的其他详细信息。