NPE caused by Modena.class.getResource("TestApp.css") - java

I'm trying to run the java-fx sample Modena that can be found here. I use Netbeans 8.0 Beta, JDK8 last release on Windows 8. I wonder why I can't even compile it.
In fact the first exception that happens is this.
I note to be a newbie in JavaFX.
The line of exception in the program is:
private static final String testAppCssUrl = Modena.class.getResource("TestApp.css").toExternalForm();
I assert that I verified and the file existed. And the example jar file can be run on my computer with my Java default configuration which is explained above.
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at com.sun.javafx.application.LauncherImpl$2.run(LauncherImpl.java:330) at com.sun.javafx.application.LauncherImpl$2.run(LauncherImpl.java:330)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:331) at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:331)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:297)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(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.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
at modena.Modena.<clinit>(Modena.java:100)
... 13 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.NullPointerException
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:362)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
... 5 more

The problem was with running only the main file with Shift+F6. I should have used F6 to run the project instead. F6 runs the project but Shift+F6 only runs the file containing the static main method without considering the project configuration.

Related

error running javafx application with Intellij

I have a javafx program that I was formerly developing in sublime text before migrating to intellij as my editing environment. As of now, I can compile and run without error through the command line (Windows). However, when I try to run it from intellij, I get the following message:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/868693306.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
at Main.setNewScene(Main.java:40)
at Main.start(Main.java:29)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/2069914884.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/646648017.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1106256089.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/151108218.run(Unknown Source)
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$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/2004449016.run(Unknown Source)
... 1 more
Process finished with exit code 1
I don't know how to fix this.
The problem turned out to be intellij having an issue with the source folder in the project directory. By moving all my java files to a new directory and reopening it in intellij as a new project with a single, correct source folder, the problem completely went away.
(As stated in the question, the code itself was functional and worked through the command line.)

web app on machine (on local computer works correctly)

I have an error:
Exception in thread "TCPSelector" java.lang.NoClassDefFoundError: org/eclipse/net4j/channel/ChannelException
at org.eclipse.net4j.internal.tcp.TCPAcceptor.createConnector(TCPAcceptor.java:218)
at org.eclipse.net4j.internal.tcp.TCPAcceptor.handleAccept(TCPAcceptor.java:188)
at org.eclipse.net4j.internal.tcp.TCPSelector.handleSelection(TCPSelector.java:230)
at org.eclipse.net4j.internal.tcp.TCPSelector.run(TCPSelector.java:179)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.eclipse.net4j.channel.ChannelException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
... 5 more
Exception in thread "TCPSelector" java.lang.ExceptionInInitializerError
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:51)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
at org.eclipse.internal.net4j.buffer.Buffer.write(Buffer.java:306)
at org.eclipse.net4j.internal.tcp.TCPConnector.handleWrite(TCPConnector.java:311)
at org.eclipse.net4j.internal.tcp.TCPSelector.handleSelection(TCPSelector.java:264)
at org.eclipse.net4j.internal.tcp.TCPSelector.run(TCPSelector.java:179)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Too many open files
at sun.nio.ch.FileDispatcherImpl.init(Native Method)
at sun.nio.ch.FileDispatcherImpl.<clinit>(FileDispatcherImpl.java:35)
... 9 more
Exception in thread "TCPSelector" java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.FileDispatcherImpl
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
at sun.nio.ch.IOUtil.write(IOUtil.java:51)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
at org.eclipse.internal.net4j.buffer.Buffer.write(Buffer.java:306)
at org.eclipse.net4j.internal.tcp.TCPConnector.handleWrite(TCPConnector.java:311)
at org.eclipse.net4j.internal.tcp.TCPSelector.handleSelection(TCPSelector.java:264)
at org.eclipse.net4j.internal.tcp.TCPSelector.run(TCPSelector.java:179)
at java.lang.Thread.run(Thread.java:745)
On local computer (local tomcat) it works fine. On machine I have this error. I'm confused, because I don't have any ideas why it doesn't work.
It looks like your operating system has run out of file descriptors:
java.io.IOException: Too many open files
if you are running on linux have a look at the ulimit command

JavaFX 2 Linux Exception

Worked on a JavaFX 2 application and while testing on linux i got:
:/tmp$ /opt/Oracle_Java/jdk1.7.0_13/bin/java -jar MyAdessoNotificationTool.jar
java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkTimer._startImpl(Ljava/lang/Runnable;I)J
at com.sun.glass.ui.gtk.GtkTimer._startImpl(Native Method)
at com.sun.glass.ui.gtk.GtkTimer._start(GtkTimer.java:24)
at com.sun.glass.ui.Timer.start(Timer.java:69)
at com.sun.javafx.tk.quantum.QuantumToolkit.finishLaunching(QuantumToolkit.java:366)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:89)
at java.lang.Thread.run(Thread.java:722)
any ideas what it is?
greetings
Kaito

Error while running advanced MTShell in MT4J

I have problem running MT4J examples. I try running he advance MTShell and I get the following errors.
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: C:\Users\Umar\Downloads\mt4j-desktop\jogl.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1872)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:109)
at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.(WindowsGLDrawableFactory.java:60)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
at org.mt4j.util.opengl.CustomPGraphicsOpenGL.allocate(CustomPGraphicsOpenGL.java:73)
at processing.core.PGraphics3D.setSize(PGraphics3D.java:326)
at processing.core.PApplet.makeGraphics(PApplet.java:1325)
at processing.core.PApplet.size(PApplet.java:1146)
at processing.core.PApplet.size(PApplet.java:1106)
at org.mt4j.MTApplication.setup(MTApplication.java:210)
at processing.core.PApplet.handleDraw(PApplet.java:1580)
at processing.core.PApplet.run(PApplet.java:1502)
at java.lang.Thread.run(Thread.java:724)
Your libraries aren't correctly linked. I answered this exact question in another post:
Error while running MT4J

Java Error, java.lang.NoClassDefFoundError: org/myorg/WordCount in Hadoop

I'm very new to Hadoop. I followed the basic tutorial about how to create word count program in hadoop. Everything was fine. I than tried to create my own map reduce, and put it in a separate jar file. When I tried to run the program, it gives me that error:
shean#ubuntu-PC:~/hadoop/bin$ hadoop jar ../weather.jar weather.Weather /user/hadoop/weather_log_sample.txt /user/hadoop/output
Warning: $HADOOP_HOME is deprecated.
Exception in thread "main" java.lang.NoClassDefFoundError: org/myorg/WordCount
at weather.Weather.main(Weather.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.ClassNotFoundException: org.myorg.WordCount
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 6 more
But the problem is , it's looking for WordCount class...
If I am not wrong you are missing the jar wordcount.jar.Please add it to build path.
My advice: you put "package" path first removed. This makes it easier not reported NoClassDefFoundError errors. javac compile time: javac-classpath "$ HADOOP_HOME/hadoop-core-1.2.0.jar: $ HADOOP_HOME/lib/commons-cli-1.2.jar"-d. / weather
litianmin#gmail.com

Categories

Resources