Ravi Kumar Pisupati Member since 2015 74 posts
Posted: 2 months ago
Last activity: 1 month 2 weeks ago

Unable to call Tesseract API to instantiate Tesseract object from Pega PE V84 after installation of necessary jar files


I am trying to use Tesseract API (open source) from Pega to implement OCR (img to txt) functionality. For that, I have done the below steps but I am unable to instantiate the object of Tesseract. 

1) Installed the "tess4j-3.4.8.jar" in the Pega PE using import wizard. This is the imp jar for Tesseract API integration.

2) Added the jar location in the System -> Settings -> Compiler like below.


Also tried to use the below in the same settings.


3) Restarted the Tomcat server to test this API from a simple java step in an activity like below


oLog.infoForced("** Hello!! ");  

net.sourceforge.tess4j.Tesseract tesseract = new net.sourceforge.tess4j.Tesseract();

//net.sourceforge.tess4j.Tesseract tesseract; //tesseract= net.sourceforge.tess4j.Tesseract.getInstance(); //net.sourceforge.tess4j.ITesseract tesseract = new net.sourceforge.tess4j.Tesseract();

//String exportPath= tools.getProperty("pxProcess.pxServiceExportPath").getStringValue(); //String filePath=exportPath+"SampleImage.jpg";

// imgfile = new;

oLog.infoForced("** Hi!!");


  //String result = tesseract.doOCR(imgfile);   //oLog.infoForced("** Text from the image!! "+result); 

}catch(Exception e)   {  oLog.infoForced("**Err "+e);   }


The highlighted line is giving PRRuntime err in the log and not printing the last oLog statement. After digging the details from tomcat console, I came to know that the err is due to the exception caused by: java.lang.NoClassDefFoundErr: net/sourceforge/test4j/Tesseract

Any expert who can help me in this regards is greatly appreciated.

Pega Platform 8.4 System Administration
Share this page LinkedIn