Tess4j与Wildfly

时间:2018-12-26 19:18:20

标签: java ocr tess4j

我想使用Wildfly 11和Tess4j库。 我有一个简单的程序,它正在运行。

    public static void main(String[] args) {
    File imageFile = new File("myPath.pdf");
    ITesseract instance = new Tesseract(); // JNA Interface Mapping
    instance.setDatapath("myPath/tessdata");
    instance.setLanguage("deu");

    System.setProperty("jna.encoding", "UTF8");
    instance.setOcrEngineMode(TessAPI.TessOcrEngineMode.OEM_DEFAULT);

    try {
        String result = instance.doOCR(imageFile);
        System.out.println(result);
    } catch (TesseractException e) {
        System.err.println(e.getMessage());
    }
}

->如果我尝试在Eclipse中以“ JAVA应用程序”运行程序,则该方法有效,但是如果我尝试从Wildfly应用程序服务器执行该程序,则会出现错误:

> trcmp(locale, "C"):Error:Assert failed:in file baseapi.cpp, line 209
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x000000012c7a78af, pid=11404, tid=0x000000000000c80b
#
# JRE version: Java(TM) SE Runtime Environment (8.0_121-b13) (build 1.8.0_121-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.121-b13 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libtesseract.dylib+0x1568af]  _ZNK7ERRCODE5errorEPKc16TessErrorLogCodeS1_z+0x183
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:

有什么想法吗? 我正在使用tess4j 4.3.0,并且还安装了Ghostscript ... 单个JAVA应用程序和Wildfly服务器之间可能会有所不同。

1 个答案:

答案 0 :(得分:0)

它抱怨语言环境。启动Java应用服务器时,需要将其设置为C

export LC_ALL=C

https://github.com/nguyenq/tess4j/issues/105