I have Spring boot Webserver project which works ok in my PC under Intellij IDEA, but it not works after distributing to the same PC as war file - NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI.
my code:
ITesseract instance = new Tesseract(); // JNA Interface Mapping
instance.setDatapath(new File(datapath).getPath());
instance.setLanguage("eng");
try {
String result = instance.doOCR(imageFile);
} catch (TesseractException e) {
System.err.println(e.getMessage());
}
I have only one maven dependency, releted to Tess4J:
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.0.0</version>
</dependency>
I've got the error after running my distributed war:
There was an unexpected error (type=Internal Server Error, status=500).
Could not initialize class net.sourceforge.tess4j.TessAPI
Full Tomcat log:
java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.tess4j.TessAPI
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:367) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:280) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:212) ~[tess4j-3.0.0.jar:3.0.0]
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:196) ~[tess4j-3.0.0.jar:3.0.0]
at ocr.OCRController.handleFileUpload(OCRController.java:127) ~[classes/:0.3.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
How can I fix the error? I have the plan to host this app in Windows Azure under Tomcat. Thank you for any help, friends!