带有Tess4j的Tesseract 3.0使Linux服务器上的应用程序崩溃 [英] Tesseract 3.0 with Tess4j crashing the Application on linux server
问题描述
我在Java应用程序中将Tess4j 3.0.0与Tesseract 3.04一起使用.在我的应用程序中,我为OCR创建了一个服务,该服务实现了Runnable.
I am using Tess4j 3.0.0 with Tesseract 3.04 in my java Application. In my application I've created a service for OCR which implements Runnable.
应用程序已在Centos 6中部署
Application is deployed in Centos 6
以下代码已投入使用.
Tesseract1 instance = new Tesseract1();
result = instance.doOCR("pathtodocument/abc.pdf");
我应用户的要求从Document Upload Service启动了一个OCR服务线程,并处理了PDF中的文本数据.
I start a thread of OCR service from Document Upload Service on request from user and process the text data from PDF.
当我测试单个请求的代码时,它可以完美工作.问题是:当我一次发送多个请求时,整个应用程序将崩溃.
When I test the code for single request it works perfect. Problem is : When I send more than one request at a time then whole application crashes.
下面是catalina.out中的错误
Below is the error in 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:
当我在Service上放置调试器并执行应用程序时,一切正常.
When I put a debugger on Service and execute the application, everything works fine.
推荐答案
为Tesseract1创建bean
create bean for Tesseract1
@Bean
public Tesseract1 tesseract() {
return new Tesseract1();
}
服务中:自动连线Tesseract
in Service : autowire Tesseract
@Autowire
private Tesseract1 instance;
将doOcr方法放入同步块
put doOcr method inside synchronized block
syncrhonized(instance){
String result = instance.doOCR(imageFile);
//other stuff
}
现在,服务线程将运行,而不会导致应用程序崩溃.
Now Service Thread will run without crashing the application.
注意:我们正在丢失同时进行的OCR,以同时请求文档.
Note: we are loosing the concurrent OCR for simultaneous document request.
这篇关于带有Tess4j的Tesseract 3.0使Linux服务器上的应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!