Why is tessdata throwing Exceptions?

流过昼夜 提交于 2019-12-02 08:38:35

问题


All is happening on MAC in SpringBoot WAR file deployed in Tomcat:

I have tesseract 4.1.0 installed (via brew on Mac).

For Tessdata - OCR on Mac

    <dependency>
        <groupId>net.sourceforge.tess4j</groupId>
        <artifactId>tess4j</artifactId>
        <version>4.4.0</version>
    </dependency>

I also updated SpringBoot today to:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

Now, when I try to run the OCR logic in tessdata (Service method in SpringBoot), I am first getting this error (on the mac):

java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;)Lcom/sun/jna/Library;

Then, if I try to OCR the Spanish png file again, I get this result:

"Could not initialize class net.sourceforge.tess4j.TessAPI"

The Tessdata code where the crash occurs seems to be:

public String doOCR(BufferedImage var1) throws TesseractException {
    return this.doOCR((BufferedImage)var1, (Rectangle)null);

I've seen postings here about this problem, but all the ones I've seen are for Windows. I also tried to load the dependency for jna just in case, but that made no difference.

Has anyone faced and fixed this issue?

The problem appears to be with the tess4j 4.4.0. If I back it out to the last version, then things work again.

Would really appreciate some ideas.


回答1:


It seems your application is loading an old JNA version. com.sun.jna.Native.load is new in JNA 5.x.x. So make sure you use the latest JNA version.

https://groups.google.com/forum/#!topic/jna-users/VKbCGUcotkg



来源:https://stackoverflow.com/questions/57379212/why-is-tessdata-throwing-exceptions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!