I have a Java desktop application that was running fine in Java 1.8; I'm upgrading to Java 1.11 for a client, and am getting the above error.
Full stacktrace:
java.lang.ExceptionInInitializerError
at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:442)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:326)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:309)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:290)
at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:274)
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.getTessAPIInstance(LoadLibs.java:83)
at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:42)
... 15 more
The Tesseract library has a Java wrapper that I've used for months successfully but now seems involved in the error, whatever it is. I've been using the same DLL and started getting this failure, and I've updated the Tesseraact DLL and the wrapper to their latest version.
More puzzling is that the application runs fine within eclipse, and only fails like this when run from a command line (Windows 10). I have uninstalled and reinstalled the DLL a couple of times, rebooted the machine each time, and am running out of things to try. I went through the entire Maven dependencies list and deleted all files found there from my repository, then refreshed the eclipse project to reload all the files in the list.
I saw one suggestion of placing a breakpoint in ZipFile, but that won't help since the problem does not appear in eclipse.
I'm willing to upgrade the Java further, but it would be nice, first, to have some knowledge of what the problem is so that I have some confidence that will fix it.
Can someone suggest what might be wrong, or strategies to find out?
Related
I have an application running in Tomcat 9.0.45 with JDK 11 (OpenJDK 11.0.11).
After upgrading some libraries (Spring 4.3.30 to 5.3.9) using maven, the application throws the following Exception:
java.lang.NoClassDefFoundError: java/lang/constant/Constable
at my.app.SomeClass.process(SomeClass.java:123) ~[classes/:?]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-5.3.9.jar:5.3.9]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
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:829) [?:?]
Caused by: java.lang.ClassNotFoundException: java.lang.constant.Constable
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364) ~[catalina.jar:9.0.45]
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187) ~[catalina.jar:9.0.45]
... 11 more
Obviously, it tries to run JRE 12 code in a JRE 11 environment.
As the Exception does not occur prior to updating the libraries, I guess some dependency got into the project that uses the JRE 12 code.
How can I find out which library/dependency causes the problem?
WebappClassLoaderBase debug log does not give any new information:
org.apache.catalina.loader.WebappClassLoaderBase.loadClass loadClass(java.lang.constant.Constable, false)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass Searching local repositories
org.apache.catalina.loader.WebappClassLoaderBase.findClass findClass(java.lang.constant.Constable)
org.apache.catalina.loader.WebappClassLoaderBase.findClass --> Returning ClassNotFoundException
Strangely, the Exception does not occur on my dev machine, so I also can't debug.
Any ideas are very much appreciated.
Edit: compiling with maven 3.8.1 using aspectj-maven-plugin 1.12.6.
The Constable interface (javadoc) was only added in Java 12.
So, your theory that the exception / stacktrace is caused by trying to run Java 12+ code on Java 11 is correct.
It is not entirely clear why this has happened. While the most recent versions of Spring are compatible with Java 16 ... they should also run on Java 11 (and indeed Java 8). It is possible that the Spring team have messed up and shipped some JARs that have been built incorrectly. But I doubt it.
I suspect that you have made a mistake in building your code. Maybe you compiled with a Java 12+ tool chain, against the Java SE 12+ runtime using a target version of Java 11?
#Stephen C pointed to the right direction - something has compiled something that way.
Turns out the machine that compiles the code, did not have Java 11 installed, but Java 16. (Still, that compiled perfectly runnable Java 11 code for Spring 4.3.30.)
I have removed Java 16 from the machine and installed Java 11 only. The code now runs without throwing the ClassNotFoundException.
As of why that happened, I still have no idea.
Using journey browser project I have set up a simple maven project in eclipse, using the dependency provided on the page, I have tried to run the code example (also provided on the page)
And I get an NPE:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
at java.desktop/java.awt.Toolkit.getEventQueue(Toolkit.java:1494)
at java.desktop/java.awt.EventQueue.isDispatchThread(EventQueue.java:1086)
at java.desktop/javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1493)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:78)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:71)
at JourneyBrowser.main(JourneyBrowser.java:13)
Caused by: java.lang.NullPointerException
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2646)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1870)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:118)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:115)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.awt.windows.WToolkit.loadLibraries(WToolkit.java:114)
at java.desktop/sun.awt.windows.WToolkit.<clinit>(WToolkit.java:129)
... 12 more
Can anyone explain what is happening and why here, I have tried this on 64bit windows with java Coretto 11(jdk11.0.7_10),I initially found a bug here, relating to loadLibray in open JDK and thought that maybe the problem, I just don't have a good enough understanding to work out how to get around it?
I'm not sure, but I think that Corretto bug is probably the one that is causing the problem. As noted, it is from their "upstream"; i.e the OpenJDK codebase. It was due to regression that appeared in jdk11.0.7 due to a backport of a fix for another problem. Apparently, the fix changes some internal JDK fields and that breaks application code. As JDK-8240521 puts it:
The backport of the JDK-8231584 changes internal JDK fields processing. The problem is that the many third-party applications copy-pasted a hack that depends on particular JDK implementation.
If I am reading the Oracle bug entries correctly, the reversion of the broken fix should be in JDK11.0.8. Alternatively, an earlier JDK 11 release than 11.0.7 shouldn't have the broken fix.
Let me know if changing your Java 11 install solves the problem. (If not, I'll see if I can get the line numbers to match up.)
This evening, I downloaded a .jar file from Jsqlquiz website. However, when I try to execute it in the terminal, I have these two displayed exceptions (I'm on Windows 10) :
Exception in thread "WindowsNativeRunloopThread" java.lang.NoSuchMethodError:
at com.sun.glass.ui.win.WinApplication.staticScreen_getScreens(Native Method)
at com.sun.glass.ui.Screen.initScreens(Screen.java:412)
at com.sun.glass.ui.Application.lambda$run$1(Application.java:152)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:830)
and
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.prism.d3d.D3DPipeline.getAdapterOrdinal(D3DPipeline.java:205)
at com.sun.javafx.tk.quantum.QuantumToolkit.assignScreensAdapters(QuantumToolkit.java:695)
at com.sun.javafx.tk.quantum.QuantumToolkit.runToolkit(QuantumToolkit.java:313)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$startup$10(QuantumToolkit.java:258)
at com.sun.glass.ui.Application.lambda$run$1(Application.java:153)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:830)
I check my java's versions to see if I have a bad/old one, but all is on date :
JDK 13.0.1
JRE 1.8.0_241
JavaFX 11.0.2
I found answers on this forum but none helped me. :
Write java -jar filename.jar in a .bat file and execute it.
Extract the folder and try to run it.
Place jdk-13.0.1\bin and Java\jre1.8.0_241\bin above the Common_Files\Oracle\Java\javapath (I deleted it finally, it was the easiest way to try to fix my problem).
If anyone here thinks they can help me, tell me! :)
Okay, after hours spent fixing my problem, I finally found it for myself!
For all those who have the same problem, follow what I will say:
There must be ONLY one version of Java on your pc (wether it's the JDK or JRE). So, only keep the java version you want and try to compile your file with java -jar fileName.jar and it should work.
I myself had the JDK and the JRE, both added to the path of the environment variables. So the error came from here.
The only thing I don't understand is why the JRE created a problem during the execution when I had put the path of the JDK above.
I have an app that pass a lint test on circleCI, but fail on local machine with the following error
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3090)
at java.base/java.lang.Class.getConstructor0(Class.java:3295)
at java.base/java.lang.Class.newInstance(Class.java:532)
at org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite.loadImplementations(ServiceLoaderLite.kt:50)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension$loadProcessors$efficientProcessorLoader$1.doLoadProcessors(Kapt3Extension.kt:83)
at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors(ProcessorLoader.kt:45)
at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors$default(ProcessorLoader.kt:28)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.loadProcessors(Kapt3Extension.kt:88)
at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:98)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:96)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:106)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:82)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:384)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:70)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:107)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:375)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:131)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:54)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:103)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:442)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$1$2.invoke(CompileServiceImpl.kt:102)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:1027)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:102)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:1069)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:1026)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:441)
at jdk.internal.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 48 more
I do not use JAXB and I have no idea where does this come from. More frustrating is I can build my app without any error.
I have tried the solutions in the following links, but none of them works for my case.
https://www.concretepage.com/questions/556
How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9
Has anyone experienced similar issues?
The JAXB APIs are considered to be J2EE APIs, therefore not present default class path in Java SE 9. In JDK 11 they are completely removed. But, these Java EE APIs that were provided in JDK 6/7/8 are still in the JDK.
Edit 10/2020:
I ran into this issue again some time ago when CircleCi update their java image from jdk8 to jdk11. I was able to solve this issue by updating the Gradle tool. Looks like in the latest version of Gradle lint no longer use JAXB APIs.
Old answer: Today I finally solve this issue. Here is what I did.
I attempted to solve this issue by reinstalling Android Studio 3.4. However I couldn't even start up Android Studio and I ran into this
java.lang.RuntimeException:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
Fatal error initializing 'com.android.tools.idea.AndroidInitialConfigurator'
Then I looked for answers and came across this page
[Can't start Android Studio][1]
[1]: https://superuser.com/questions/1391452/cant-start-android-studio
I reverted back to use jdk 8.
Android Studio 3.4 finally started up, and JAXBException was gone.
I got this error message in the console when I tried to run, I just switched laptops and I've wiped my old one. This project has always been stored in a USB so I use that to run it on my new laptop. (So I had to re-download all the applications), I need this to fix so bad due to its my project for class and I haven't record it and I'm supposed to do that and I don't want to fail the class please could u help thank u:
java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
at java.base/java.lang.Class.getMethodsRecursive(Class.java:3260)
at java.base/java.lang.Class.getMethod0(Class.java:3246)
at java.base/java.lang.Class.getMethod(Class.java:2065)
at processing.core.PApplet.runSketch(PApplet.java:10751)
at processing.core.PApplet.main(PApplet.java:10548)
at processing.core.PApplet.main(PApplet.java:10530)
at robothead.Robothead.main(Robothead.java:8)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.QuitHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 9 more
I at first download JDK 10 and I read it only works with JDK 8 so I download that and delete JDK 10 in hopes that stuff will return back to normal and it does not works. Also the project, I did it in java oxygen and I downloaded photon on my new laptop and click on the yes I want to convert the files thing so I decided to make a new workspace and copy paste the code but still got that error?Before it was MacBook Air and I switch to the MacBook Pro.
You are mixing up a lot of things.
The basic problem is that starting with Java 9 oracle made changes that lead to such errors ( see https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-C86F7403-7D7C-456F-8873-18C7F1BEDE2F).
So, in order to get this to work, you have to ensure that Java 8 is used. And that your Java 10 installation was really, fully removed. You should then check your eclipse settings to also ensure that it is pointing to Java 8.