【问题标题】:tomcat 7 can't use jna to load my shared library with absolute pathtomcat 7 无法使用 jna 以绝对路径加载我的共享库
【发布时间】:2014-05-25 14:45:07
【问题描述】:

我的代码:

static final boolean WINDOWS = System.getProperty("os.name").toLowerCase().startsWith("windows");
public static final String LIB_NAME = "libtesseract302";
public static final String LIB_NAME_NON_WIN = "/home/xxx/libtesseract.so";
public static final TessAPI INSTANCE = (TessAPI) Native.loadLibrary(WINDOWS ? LIB_NAME : LIB_NAME_NON_WIN, TessAPI.class)

它适用于 tomcat 6 当我使用tomcat 7时,它不起作用。

java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract.so': Native library (linux-x86/libtesseract.so) not found in resource path.....

我无权更改jvm Dpath。我也尝试使用

NativeLibrary.addSearchPath("libtesseract","/home/xxx/")

但它也不起作用。那么这种情况的解决方案是什么?

【问题讨论】:

  • 如果您解释了如何它不起作用会有所帮助。
  • 99% 的答案是在 tomcat 7 上启用了安全管理器,它可以防止访问应用程序外部的文件,包括这里提到的库。解决方法是将库移动到 JNA 搜索路径中。

标签: java tomcat tesseract jna loadlibrary


【解决方案1】:

你们是同一个jvm架构吗??64位和32位之间的JNA库无法访问

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 2021-12-14
    • 2017-07-11
    • 2015-01-11
    • 2018-04-07
    • 2016-02-26
    相关资源
    最近更新 更多