带有 Tess4j 的 Tesseract 3.0 使 linux 服务器上的应用程序崩溃

Tesseract 3.0 with Tess4j crashing the Application on linux server

我在 java 应用程序中使用 Tess4j 3.0.0 和 Tesseract 3.04。 在我的应用程序中,我为实现 Runnable 的 OCR 创建了一个服务。

应用部署在Centos 6

以下代码已投入使用。

Tesseract1 instance = new Tesseract1();
result = instance.doOCR("pathtodocument/abc.pdf");

我根据用户的请求从文档上传服务启动了一个 OCR 服务线程,并处理来自 PDF 的文本数据。

当我测试单个请求的代码时,它运行完美。 问题是: 当我一次发送多个请求时,整个应用程序就会崩溃。

下面是catalina.out

中的错误
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f9514000078, pid=12979, tid=140277704374016
#
# JRE version: Java(TM) SE Runtime Environment (8.0_74-b02) (build 1.8.0_74-b02)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.74-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  0x00007f9514000078
#
# 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:
# //hs_err_pid12979.log
#
# If you would like to submit a bug report, please visit:

当我将调试器放在服务上并执行应用程序时,一切正常。

为 Tesseract1 创建 bean

@Bean
public Tesseract1 tesseract() {
    return new Tesseract1();
}

服务中:自动装配 Tesseract

@Autowire
private Tesseract1 instance;

将 doOcr 方法放在同步块中

syncrhonized(instance){
   String result = instance.doOCR(imageFile);
   //other stuff
}

现在服务线程 运行 不会使应用程序崩溃。

注意:我们将失去同时文档请求的并发 OCR。