8月19

Tess4j问题:java.lang.UnsatisfiedLinkError:在instance.doOCR(imageFile)中找不到指定的模块

| |
11:52编程杂谈  From: 本站原创
Tess4j Issue in Windows: java.lang.UnsatisfiedLinkError: The specified module could not be found in instance.doOCR(imageFile)

Tess4j在本地跑的时候没有问题,放到windows server2008 r2服务器上的时候就报下面找不到模块的错误:

java.lang.UnsatisfiedLinkError: The specified module could not be found.

       at com.sun.jna.Native.open(Native Method) ~[jna.jar:4.2.1 (b0)]
       at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:263) ~[jna.jar:4.2.1 (b0)]
       at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:403) ~[jna.jar:4.2.1 (b0)]
       at com.sun.jna.Library$Handler.<init>(Library.java:147) ~[jna.jar:4.2.1 (b0)]
       at com.sun.jna.Native.loadLibrary(Native.java:502) ~[jna.jar:4.2.1 (b0)]
       at com.sun.jna.Native.loadLibrary(Native.java:481) ~[jna.jar:4.2.1 (b0)]
       at net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(Unknown Source) ~[tess4j-3.0.jar:na]
       at net.sourceforge.tess4j.TessAPI.<clinit>(Unknown Source) ~[tess4j-3.0.jar:na]
       at net.sourceforge.tess4j.Tesseract.init(Unknown Source) ~[tess4j-3.0.jar:na]
       at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
       at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
       at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source) ~[tess4j-3.0.jar:na]
       at ocr.OCRController.handleFileUpload(OCRController.java:109) ~[classes/:na]
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
       at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]

我搜索并发现人们建议更新Visual VisualC++可重分发软件包,我做了Visual Studio 2013,但结果却没有帮助,我仍然得到同样的问题。我不知道我做错了什么,下面是我的代码。

ITesseract instance = new Tesseract(); // JNA Interface Mapping

instance.setDatapath(new File(datapath).getPath());
instance.setLanguage("eng");      
try {
       String result = instance.doOCR(imageFile); //error here
} catch (TesseractException e) {
       System.err.println(e.getMessage());
}


此问题与Windows无关。
我已经把版本换回3.0
<dependency>
       <groupId>net.sourceforge.tess4j</groupId>
       <artifactId>tess4j</artifactId>
       <version>3.0.0</version>
</dependency>
替换所有以前的maven依赖项,就好了。

来源:Heck's Blog
地址:https://www.heckjj.com/post/512/
转载时须以链接形式注明作者和原始出处及本声明,否则将追究法律责任,谢谢配合!
阅读(59) | 评论(0) | 引用(0)