[Solved] Nifty : NPE thrown on Nifty#render(boolean)

Recently I have started working with jMonkeyEngine, and the first thing I went to really learn is Nifty. I started following the tutorial on this page (to learn the markup style), and I think I have written everything appropriately. I did do some pre-research, and I didn’t find anything that seemed to be exactly the same issue I’m having (based on where the error was thrown).

To start with the error, I run it, and it crashes with a JOptionPane telling me NullPointerException.

The stacktrace:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
	at com.jme3.niftygui.RenderDeviceJme.renderQuad(RenderDeviceJme.java:342)
	at de.lessvoid.nifty.render.ScalingRenderDevice.renderQuad(ScalingRenderDevice.java:67)
	at de.lessvoid.nifty.render.NiftyRenderEngineImpl.renderQuad(NiftyRenderEngineImpl.java:213)
	at de.lessvoid.nifty.elements.render.PanelRenderer.render(PanelRenderer.java:54)
	at de.lessvoid.nifty.elements.Element.renderElement(Element.java:735)
	at de.lessvoid.nifty.elements.Element.render(Element.java:713)
	at de.lessvoid.nifty.screen.Screen.renderLayers(Screen.java:316)
	at de.lessvoid.nifty.Nifty.render(Nifty.java:322)
	at ecrosogames.hermit.MainMenuAppState.render(MainMenuAppState.java:55)
	at com.jme3.app.state.AppStateManager.render(AppStateManager.java:300)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
	at java.lang.Thread.run(Unknown Source)

(Full Console Output)
When I looked at my class MainMenuAppState.java:55, the error was this line:

if (nifty != null) nifty.render(true);

I find it weird that this would be throwing the error, but there must be a problem on my end somewhere.

For more code, here are some links (via Pastebin):

It’s been like 2-3 years since I did anything with Nifty, but I never had to call render() myself. That’s a bit odd.

Wow, I knew it was going to be silly. I don’t have any docs set up with the Nifty jar (using eclipse for my workspace), but I took the guess while scrolling through the methods that I need to manually call the render method. Removing that method fixed it.

EDIT: Probably would be a good idea to use the jMonkeyEngine SDK.