Reputation: 21
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.
Application is deployed in Centos 6
below code is in Service.
Tesseract1 instance = new Tesseract1();
result = instance.doOCR("pathtodocument/abc.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.
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:
When I put a debugger on Service and execute the application, everything works fine.
Upvotes: 1
Views: 1076
Reputation: 21
create bean for Tesseract1
@Bean
public Tesseract1 tesseract() {
return new Tesseract1();
}
in Service : autowire Tesseract
@Autowire
private Tesseract1 instance;
put doOcr method inside synchronized block
syncrhonized(instance){
String result = instance.doOCR(imageFile);
//other stuff
}
Now Service Thread will run without crashing the application.
Note: we are loosing the concurrent OCR for simultaneous document request.
Upvotes: 1