gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:45:20 32 4
gpt4 key购买 nike

我在我的 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();
}

在服务中: Autowiring Tesseract

@Autowire
private Tesseract1 instance;

将 doOcr 方法放在同步块(synchronized block)中

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

现在服务线程将运行而不会导致应用程序崩溃。

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

关于java - 带有 Tess4j 的 Tesseract 3.0 使 Linux 服务器上的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37832331/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com