I am running a Java desktop application on Windows 10 Pro using Tess4j; it
was working fine with Java 1.8, am now trying to get it to run with Java 11
(11.0.15.1). When it calls net.sourceforge.tess4j.Tesseract.doOCR(BufferedImage
bi), it gets a Throwable ExceptionInInitializerError, with a 'cause'
exception indicating a call to
net.sourceforge.tess4j.util.LoadLibs.getTesseractLibName().
Oddly enough, the application works fine from within eclipse, but fails
running on its own (for instance, running "java -jar program.jar" from a
cmd window). As I said, it was running with Java 1.8, and I might be able
to get it running again by uninstalling Java and reinstalling that JRE, but
there are other people that are going to use the application and it is not
reasonable to expect them to use a Java version that is that old.
I had the Maven dependency:
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.4.1</version>
The only copy of tess4j-4.1.1.jar on my hard drive is in my
.m2\repository\net\sourceforge\tess4j\tess4j\4.4.1. I have twice deleted it
and updated my maven configuration to restore it, to insure it is not
corrupted.
I noticed that this is not the most recent Tess4j, so updated the
dependency to 5.4.0 and rebuilt. This has the same results: works in
eclipse, not from command line.
The ExceptionInInitializerError is caused by an IllegalStateException: zip
file closed error. Documentation indicates this could be a corrupted jar
file or something similar. I don't know what jar file could be involved
except the tess4j, and I've replaced that twice as I've said.
I've also tried this with two versions of the Tesseract-OCR dll --
5.0.1.20220118 and v5.2.0.20220712; they were both installed for "anyone on
this computer" with default options. They give the same results.
Can someone help me figure out what's wrong?
Stack trace:
java.lang.ExceptionInInitializerError
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:427)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:311)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:294)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:275)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:259)
at
drivingrecordtool.file.DrivingRecordPDFTextReader.getOCRText(DrivingRecordPDFTextReader.java:152)
at
drivingrecordtool.file.DrivingRecordPDFTextReader.getText(DrivingRecordPDFTextReader.java:46)
at
drivingrecordtool.file.DrivingRecordFileReader.doInBackground(DrivingRecordFileReader.java:78)
at
drivingrecordtool.file.DrivingRecordFileReader.doInBackground(DrivingRecordFileReader.java:1)
at java.desktop/javax.swing.SwingWorker$1.call(SwingWorker.java:304)
at
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.desktop/javax.swing.SwingWorker.run(SwingWorker.java:343)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalStateException: zip file closed
at java.base/java.util.zip.ZipFile.ensureOpen(ZipFile.java:913)
at java.base/java.util.zip.ZipFile.getEntry(ZipFile.java:348)
at java.base/java.util.zip.ZipFile$1.getEntry(ZipFile.java:1130)
at java.base/java.util.jar.JarFile.getEntry0(JarFile.java:586)
at java.base/java.util.jar.JarFile.getEntry(JarFile.java:516)
at
java.base/sun.net.www.protocol.jar.URLJarFile.getEntry(URLJarFile.java:131)
at java.base/java.util.jar.JarFile.getJarEntry(JarFile.java:478)
at
java.base/jdk.internal.loader.URLClassPath$JarLoader.getResource(URLClassPath.java:945)
at
java.base/jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:315)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:455)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
at java.base/java.security.AccessController.doPrivileged(Native
Method)
at
java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at
net.sourceforge.tess4j.util.LoadLibs.getTesseractLibName(LoadLibs.java:95)
at
net.sourceforge.tess4j.util.LoadLibs.getTessAPIInstance(LoadLibs.java:85)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
... 15 more
--
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tesseract-ocr/56ccf988-a094-4442-9536-b4f70ba6aed2n%40googlegroups.com.