I've got a project that runs fine in IntelliJ IDEA 2017 (a simple board game), which is a JavaFX Project. I've set this up to export as a jar using File > Project Structure > Artifacts > + > JAR > From Module With Dependencies which generated a jar file.
However when I run this jar using java -jar program.jar, I get the following exception:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: sun/plugin/dom/exception/InvalidStateException
at main.GameManager.<init>(GameManager.java:23)
at main.Main.start(Main.java:48)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
... 1 more
Caused by: java.lang.ClassNotFoundException: sun.plugin.dom.exception.InvalidStateException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
Exception running application main.Main
The important part of that is the NoClassDefFoundError from main.GameManager, line 23. This line is creating a new instance of an object, the class for which is in a separate package.
Any ideas on how to fix this issue?
Thanks!
Related
I created quite complex project with JavaFX and now I'm having some trouble deploying it, as I never deployed any app in Java before.
I tried using Intellij "Build artificial" but I always get "Error: corrupted jarfile" when I try to open the the Jar it builds.
Any suggestions? I'm using external libraries from Maven and some local ones too if it helps...
Edit:
Ok I changed some of the settings in the Make Artificial, now I don't get that error.
I get this Exception, seems it can't file the fxml file...
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml/javafx.fxml.FXMLLoader.load(Unknown Source)
at sample.Main.start(Main.java:20)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
at
javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
... 1 more
Exception running application sample.Main
SOLVED!: just played with the fxml files patches and it fixed it...
I'm following this guide: https://docs.oracle.com/cd/E56351_01/doc.30/e87809/getting-started-with-RESTful-services.htm#AELIG90200
but I got stuck in "F.2 Create a RESTful Service from a SQL Query".
In the folder where Oracle REST Data Services was installed, I entered the following command in a command prompt:
java -jar ords.war user test_developer "SQL Developer"
and I got this error:
java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.base/java.lang.Class.getDeclaredFields(Unknown Source)
at oracle.dbtools.injector.impl.__Reflections.constantFields(__Reflectio ns.java:30)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:356)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:378)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:310)
at oracle.dbtools.common.di.Services$Builder.add(Services.java:409)
at oracle.dbtools.common.di.Services$Builder.load(Services.java:474)
at oracle.dbtools.common.app.ApplicationContext.loadServices(Application Context.java:167)
at oracle.dbtools.cmdline.Commands.main(Commands.java:345)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at oracle.dbtools.jarcl.Entrypoint.main(Entrypoint.java:58)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandl er
at java.base/java.lang.ClassLoader.findClass(Unknown Source)
at oracle.dbtools.jarcl.JarClassLoader.findClass(JarClassLoader.java:63)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.base/java.lang.Class.getDeclaredFields(Unknown Source)
at oracle.dbtools.injector.impl.__Reflections.constantFields(__Reflectio ns.java:30)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:356)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:378)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:310)
at oracle.dbtools.common.di.Services$Builder.add(Services.java:409)
at oracle.dbtools.common.di.Services$Builder.load(Services.java:474)
at oracle.dbtools.common.app.ApplicationContext.loadServices(Application Context.java:167)
at oracle.dbtools.cmdline.Commands.main(Commands.java:345)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at oracle.dbtools.jarcl.Entrypoint.main(Entrypoint.java:58)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/java.lang.ClassLoader.findClass(Unknown Source)
at oracle.dbtools.jarcl.JarClassLoader.findClass(JarClassLoader.java:63)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredFields0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.base/java.lang.Class.getDeclaredFields(Unknown Source)
at oracle.dbtools.injector.impl.__Reflections.constantFields(__Reflectio ns.java:30)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:356)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:378)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.add(InjectorImpl.ja va:310)
at oracle.dbtools.common.di.Services$Builder.add(Services.java:409)
at oracle.dbtools.common.di.Services$Builder.load(Services.java:474)
at oracle.dbtools.common.app.ApplicationContext.loadServices(Application Context.java:167)
at oracle.dbtools.cmdline.Commands.main(Commands.java:345)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at oracle.dbtools.jarcl.Entrypoint.main(Entrypoint.java:58)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/java.lang.ClassLoader.findClass(Unknown Source)
at oracle.dbtools.jarcl.JarClassLoader.findClass(JarClassLoader.java:63)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
null
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at oracle.dbtools.jarcl.Entrypoint.main(Entrypoint.java:58)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Unknown Sour ce)
at java.base/java.lang.Class.getDeclaredConstructors(Unknown Source)
at oracle.dbtools.injector.impl.__Reflections.getConstructorsAnnotatedWi th(__Reflections.java:56)
at oracle.dbtools.injector.impl.Constructors.getInjectConstructors(Const ructors.java:39)
at oracle.dbtools.injector.impl.DependencyGraph.annotatedConstructor(Dep endencyGraph.java:416)
at oracle.dbtools.injector.impl.DependencyGraph.dependencies(DependencyG raph.java:204)
at oracle.dbtools.injector.impl.DependencyGraph.graph(DependencyGraph.ja va:297)
at oracle.dbtools.injector.impl.DependencyGraph.<init>(DependencyGraph.j ava:55)
at oracle.dbtools.injector.impl.DependencyGraph.<init>(DependencyGraph.j ava:37)
at oracle.dbtools.injector.impl.DependencyGraph$Builder.build(Dependency Graph.java:490)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.build(InjectorImpl. java:385)
at oracle.dbtools.injector.impl.InjectorImpl$Builder.build(InjectorImpl. java:310)
at oracle.dbtools.common.di.Services$Builder.build(Services.java:416)
at oracle.dbtools.common.di.Services$Builder.build(Services.java:431)
at oracle.dbtools.conf.ConfigurationSettings.injectConfigurationSettingV alues(ConfigurationSettings.java:48)
at oracle.dbtools.common.app.ApplicationContext.<init>(ApplicationContex t.java:98)
at oracle.dbtools.common.app.ApplicationContext.<init>(ApplicationContex t.java:48)
at oracle.dbtools.cmdline.Commands.main(Commands.java:345)
... 5 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandl er
at java.base/java.lang.ClassLoader.findClass(Unknown Source)
at oracle.dbtools.jarcl.JarClassLoader.findClass(JarClassLoader.java:63)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 24 more
Why is this for? and How to fix it?
An issue with Java 9 and addressed in this SO post
Your issue can be worked around by issuing this
java -jar --add-modules java.xml.bind ords.war user test_developer "SQL Developer"
Also, if you're wanting to build RESTful Services with ORDS, you can also use SQL Developer and simply connect to the REST enabled schema and use the REST feature in the connection tree. I talk about this here.
I have a javafx application which is not properly exporting to a runnable jar file from eclipse. When exported the .jar file does not properly run and the GUI does not appear. Below is the Manifest File.
Manifest-Version: 1.0
Class-Path: .
Main-Class: gameaspects.SourceCodeVersion9
Here is the export interface:
Exporting the file produces no errors or warnings from eclipse.
Running the application from cmd I get the following error:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Unknown Source)
Caused by: java.nio.file.NoSuchFileException: .\music
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(Unknown Source)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.readAttributes(Unknown Source)
at java.nio.file.Files.readAttributes(Unknown Source)
at java.nio.file.FileTreeWalker.getAttributes(Unknown Source)
at java.nio.file.FileTreeWalker.visit(Unknown Source)
at java.nio.file.FileTreeWalker.walk(Unknown Source)
at java.nio.file.FileTreeIterator.<init>(Unknown Source)
at java.nio.file.Files.find(Unknown Source)
at gameaspects.SourceCodeVersion9.start(SourceCodeVersion9.java:81)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application gameaspects.SourceCodeVersion9
The code that I believe that this is referring to is this:
List<String> result = Files.find(Paths.get(".\\music"), 100,
(p, a) -> p.toString().toLowerCase().endsWith(".mp3"))
.map(path -> path.toString())
.collect(Collectors.toList());
The .\music refers to the source folder music that is present in my application.
If any other information is needed to diagnose this issue please comment below and I will add it.
Ok using java -jar FileName.jar in command prompt and then using the stack trace to debug my code I was able to find the error with my application.
While I am running Main class related to Jar file I got following error. Some one please help me. Thanks.
D:\data\Gateway\dist>java -jar Gateway.jar com.Application
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractApplicationContext
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.AbstractApplicationContext
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
The message
java.lang.NoClassDefFoundError:
org/springframework/context/support/AbstractApplicationContext
indicates that the jar org.springframework.context must be added to the classpath.
I'm trying to launch a runnable JAR file via web start, but am encountering an error with java not being able to find an external JAR (I think). When running the JNLP file, JWS starts, but then states that the application cannot be opened due to this error:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
at DevChat.canConnect(DevChat.java:326)
at DevChat.<init>(DevChat.java:89)
at DevChat.main(DevChat.java:348)
... 9 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.net.ftp.FTPClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
The external JAR file mentioned, apache commons, is embedded in the runnable JAR and the JAR runs fine on it's own, just not in JWS. Suggestions?