java - Leadtools.RasterException : Native Library Ltkrnx. dll 已加载到另一个类加载器中

标签 java spring-boot ocr leadtools-sdk

我遇到了这个问题:

native 库 Ltkrnx.dll 已加载到另一个类加载器中

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

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

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

由以下原因引起:leadtools.RasterException: native 库 C:\LEADTOOLS 20\Bin\CDLL\x64\Ltkrnx.dll 已在另一个类加载器中加载

最佳答案

您是否在 2 个不同的 Web 应用程序中使用 LEADTOOLS?如果是,以下答案可能会帮助您解决问题: java.lang.UnsatisfiedLinkError: Native Library XXX.so already loaded in another classloader

由于该问题是关于 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.

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

  1. 此问题的详细信息(您遇到的异常(exception)情况,LEADTOOLS 版本 20,64 位,Tomcat 8)
  2. 您的 LEADTOOLS 产品序列号(请勿将其发布在此处!)。如果您仍在评估并且没有序列号,只需提及即可。
  3. 到目前为止,您已尝试过哪些方法来解决该问题以及得到了什么结果(例如上面提到的答案)。
  4. 有关您的操作系统、IDE 或一般编程环境的其他详细信息。

关于java - Leadtools.RasterException : Native Library Ltkrnx. dll 已加载到另一个类加载器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56151457/

相关文章:

java - 有没有办法将我的 Java 函数传递给 try-catch 函数?

java - TabPagerIndicator 与抽屉导航出错

Java变量对象搜索列表

java - AWS SDK 2 承担角色

java - @DataJpaTest 使用存储库保存实体,无法使用 JdbcTemplate 检索数据

r - R中的正方体无法识别 "&"

PHP Azure OCR - 转换数组中的 JSON

java - 未弃用的 StringBufferInputStream 等价物

java - 从 java 中使用 Tesseract

java - 使用外键关系编排 Spring Boot CrudRepositories