[SOLVED] Annoying exception in some examples

Hi, I am new to JME3, most examples of JmeTests are running fine, but some never run successfully.

For instance, TestSpotLightShadows, TestNiftyToMash, TestMultiplesFilters, TestOctree will throw exception and failed to run. I tried on different PC with onboard or discrete GPU.

How to run those test properly with exception?

“throws an exception” is a nearly useless statement without knowing which exception and the stack trace.

1 Like
@limwerks said: Annoying exception
which?
@limwerks said: in some examples
which?

I list two example with exceptions

>> TestSpotLightShadows

“Error in application” dialog prompt:
Uncaught exception thrown in Thread[LWJGL Render Thread,6,main]
NullPointerException

Output window:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.NullPointerException
at com.jme3.post.FilterPostProcessor.updateLastFilterIndex(FilterPostProcessor.java:365)
at com.jme3.post.FilterPostProcessor.setFilterState(FilterPostProcessor.java:340)
at com.jme3.post.FilterPostProcessor.addFilter(FilterPostProcessor.java:112)
at jme3test.light.TestSpotLightShadows.setupLighting(TestSpotLightShadows.java:116)
at jme3test.light.TestSpotLightShadows.simpleInitApp(TestSpotLightShadows.java:177)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)

>>TestNiftyToMash

“Error in application” dialog prompt
Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
RuntimeException: com.jme3.assets.AssetNotFoundException: all/intro.xml

Output window:

Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: igdumdim64
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 10.18.10.3412
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Intel
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.2.0 - Build 10.18.10.3412
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: IntelÂŽ HD Graphics 4600
Apr 17, 2014 1:09:25 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.20 - Build 10.18.10.3412
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
Apr 17, 2014 1:09:25 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
Apr 17, 2014 1:09:26 PM com.jme3.asset.DesktopAssetManager locateAsset
WARNING: Cannot locate resource: all/intro.xml
Apr 17, 2014 1:09:26 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.RuntimeException: com.jme3.asset.AssetNotFoundException: all/intro.xml
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:577)
at de.lessvoid.nifty.Nifty.fromXml(Nifty.java:455)
at jme3test.niftygui.TestNiftyToMesh.simpleInitApp(TestNiftyToMesh.java:67)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)
Caused by: com.jme3.asset.AssetNotFoundException: all/intro.xml
at com.jme3.niftygui.NiftyJmeDisplay$ResourceLocationJme.getResourceAsStream(NiftyJmeDisplay.java:82)
at de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader.getResourceAsStream(NiftyResourceLoader.java:65)
at de.lessvoid.nifty.Nifty.getResourceAsStream(Nifty.java:1583)
at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:569)
… 6 more

1 Like

My PC config:

PC 1
Windows Vista Ultimate 64-bit
Core2 Quad 9550
8GB RAM
MSI 290x Gaming

PC 2
Windows 8.1 64-bit
Core i5 4570
8GB RAM
Onboard graphic

Are those exceptions are normal? Or is it Windows issue?

The last error is normal because the nifty demo is not shipped with jME anymore. You can download it and place it in the location the error complains about.

I found TestMultiplesFilters, TestOctree exceptions maybe cause by missing asset.

But how about TestSpotLightShadows? There is severe problem: NullPointerException. I would like to see the capability of spot light with shadow.

1 Like

I’ve reproduced the bug. If you simply want to run the test, I suggest commenting out line 116 of TestSpotLightShadows.java in the jme3test.light package.

1 Like

FilterPostProcessor seems to give this NPE whenever the first filter added is a disabled filter. Here is a simple app to demonstrate the bug:
[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.GammaCorrectionFilter;

public class Main extends SimpleApplication {

public static void main(String[] args) {
    Main app = new Main();
    app.start();
}

@Override
public void simpleInitApp() {
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    GammaCorrectionFilter gcf = new GammaCorrectionFilter(1f);
    gcf.setEnabled(false);
    fpp.addFilter(gcf);
}

}
[/java]

The best workaround I’ve found is to disable the filter after it’s been added to the FPP.

1 Like

Note that the NPE occurs in 3.0.7 but not in recent trunk versions of JME3. Here is a proposed fix to FilterPostProcessor.java in 3.0.7:

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -359,7 +359,7 @@
                 return;
             }
         }
-        if (lastFilterIndex == -1) {
+        if (isInitialized() && lastFilterIndex == -1) {
             //There is no enabled filter, we restore the original framebuffer 
             //to the viewport to bypass the fpp.
             viewPort.setOutputFrameBuffer(outputBuffer);
1 Like

I just discovered that my proposed fix exactly matches SVN change #10920 which @Nehon put into JME3’s ‘trunk’ back in November. Apparently I missed this one back in March when I proposed the list of changes to be back-ported into ‘3.0stable’.

@sgold said: I've reproduced the bug. If you simply want to run the test, I suggest commenting out line 116 of TestSpotLightShadows.java in the jme3test.light package.

Thanks, I can run the TestSpotLightShadows, and I found TestPointLightShadows has same problem, after commenting out line 121, I can run the test.

What is fpp.addFilter(plsf); and why it crash the program?

@sgold said: I just discovered that my proposed fix exactly matches SVN change #10920 which @Nehon put into JME3's 'trunk' back in November. Apparently I missed this one back in March when I proposed the list of changes to be back-ported into '3.0stable'.
Oh cool. I did make a stand alone commit in the end. Thanks Steve, your thoroughness is really appreciated.
1 Like
@limwerks said: Thanks, I can run the TestSpotLightShadows, and I found TestPointLightShadows has same problem, after commenting out line 121, I can run the test.

What is fpp.addFilter(plsf); and why it crash the program?

There are two mechanisms for adding shadows to a JME scene. One is what’s called a shadow filter, the other is what’s called a shadow renderer. Filters work via a special scene processor called the FilterPostProcessor.

TestSpotLightShadows demonstrates both mechanisms, but since it only uses one mechanism at a time, starting with the shadow renderer, it disables the shadow filter at startup.

We made a change between JME 3.0.5 and 3.0.7 to address a different issue, and it has the unfortunate side-effect that when a disabled filter is added to a FilterPostProcessor, you get a NullProtectionException. If you add the filter first and then disable it, you will work around the bug in 3.0.7.

Thank you for the explanation. Should I downgrade to 3.0.5?

@limwerks said: Thank you for the explanation. Should I downgrade to 3.0.5?

I don’t recommend that.

I recommend updating to 3.0.8, which is now available from the Update Center.

After upgraded to 3.0.8, the examples are running fine now. Thank you.

2 Likes