NullPointerException with Nifty

Can anyone give me any hints on why im getting this exception. It doesnt happen all the time.

It seems to happen when I hit the button to goto my Nifty GUI Screen



[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]


at de.lessvoid.nifty.screen.Screen.forwardMouseEventToLayers(

at de.lessvoid.nifty.screen.Screen.mouseEvent(

at de.lessvoid.nifty.Nifty.forwardMouseEventToScreen(

at de.lessvoid.nifty.Nifty.access$1100(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processEvent(

at de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl.processMouseEvent(

at com.jme3.niftygui.InputSystemJme.onMouseButtonEventQueued(

at com.jme3.niftygui.InputSystemJme.forwardEvents(

at de.lessvoid.nifty.Nifty.update(

at com.jme3.niftygui.InputSystemJme.endInput(

at com.jme3.input.InputManager.processQueue(

at com.jme3.input.InputManager.update(



at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(



Inconsistency detected by dl-close.c: 736: _dl_close: Assertion `map->l_init_called’ failed![/java]

You being on Linux isn’t helping me, but it seems (some library) is having some inconsistency… (that’s on the last line)

I can’t find that line in the current Nifty probably because the source has been changed on other places. Can you try to find the line in the source for the specific nifty/jme build you’re using?

Im using the jar file from the nightly build


I looked in the SorceForge

I think the code is[java]





283 * Handle Mouse Events for this screen. Forwards the event to the layers.

284 * @param inputEvent MouseInputEvent

285 * @return true when processed and false when not

286 */

287 public final boolean mouseEvent(final MouseInputEvent inputEvent) {

288 if (!popupElements.isEmpty()) {

289 return forwardMouseEventToLayers(popupElements, inputEvent);

290 } else {

291 return forwardMouseEventToLayers(layerElements, inputEvent);

292 }

293 }


295 /

296 * forward mouse event to the given layer list.

297 * @param layerList layer list

298 * @param inputEvent TODO

299 * @return TODO

300 */

301 private boolean forwardMouseEventToLayers(final List < Element > layerList, final MouseInputEvent inputEvent) {

302 mouseOverHandler.reset();


304 long eventTime = timeProvider.getMsTime();

305 for (int i=0; i<layerList.size(); i++) {

306 Element layer = layerList.get(i);

307 layer.buildMouseOverElements(inputEvent, eventTime, mouseOverHandler);

308 }


310 if (log.isLoggable(Level.FINE)) {

311 log.fine(mouseOverHandler.getInfoString());

312 }


314 mouseOverHandler.processMouseOverEvent(rootElement, inputEvent, eventTime);

315 mouseOverHandler.processMouseEvent(inputEvent, eventTime);


317 return mouseOverHandler.hitsElement();

318 }


Any thoughts?

mouseOverHandler should never be null o_O It’s created in the Screen constructor. No idea at the moment. Do you have any unusual things going on, like calling Nifty from multiple screens.

When all else failes, would it be possible to zip the whole source in a way that I can E-A-S-I-L-Y build and test it here?

I commented out the nifty==null check in my code and the error goes away.

But that reintroduces a old error

I have 3 Nifty Screens

Menu (ESC)

Console/Chat (TAB)


If Im in my menu screen and I hit the I key by accident it will open both Nifty Screens

I guess I need to know if I should kill nifty each time or if I should hold a reference to it and make it open different


[java]nifty.fromXml("Interfaces/niftytest.xml", "start");[/java]


public void initNiftyGui() {

Logger.getLogger("de.lessvoid").setLevel( Level.OFF );

// if(nifty==null){

NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,

inputManager, audioRenderer, guiViewPort);

nifty = niftyDisplay.getNifty();


// }

nifty.fromXml("Interfaces/niftytest.xml", "start");



My Project is here