Im haing a problem where the program will randomly give these messages
Failed to create display:
IllegalStateException: From Thread Thread[LWJGL Render Thread,6,main]: Thread[LWJGL Render Thread,6,main] alread has context current.
Uncaught exception thrown in Thread[Headless Application Thread,6,main] Null pointer exception.
Im running a headless server and graphical client under same app. This only occurs randomly, I would about 60% it will run properly. When it crashes I can even relaunch the client/server combination without restarting the app and it will work. What might be causing this?
SEVERE: Uncaught exception thrown in Thread[Headless Application Thread,6,main]
java.lang.NullPointerException
at com.jme3.app.StatsAppState.loadStatsView(StatsAppState.java:187)
at com.jme3.app.StatsAppState.initialize(StatsAppState.java:161)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
at com.jme3.system.NullContext.run(NullContext.java:130)
at java.lang.Thread.run(Thread.java:722)
Aug 21, 2014 6:35:05 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread
WARNING: null
java.lang.IllegalStateException: From thread Thread[LWJGL Renderer Thread,6,main]: Thread[LWJGL Renderer Thread,6,main] already has the context current
at org.lwjgl.opengl.ContextGL.checkAccess(ContextGL.java:184)
at org.lwjgl.opengl.ContextGL.forceDestroy(ContextGL.java:241)
at org.lwjgl.opengl.DrawableGL.destroy(DrawableGL.java:130)
at org.lwjgl.opengl.Display$5.destroy(Display.java:834)
at org.lwjgl.opengl.Display.destroy(Display.java:1086)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:121)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)
Aug 21, 2014 6:35:05 PM com.jme3.app.Application handleError
SEVERE: Failed to create display
java.lang.IllegalStateException: From thread Thread[LWJGL Renderer Thread,6,main]: Thread[LWJGL Renderer Thread,6,main] already has the context current
at org.lwjgl.opengl.ContextGL.checkAccess(ContextGL.java:184)
at org.lwjgl.opengl.ContextGL.makeCurrent(ContextGL.java:189)
at org.lwjgl.opengl.DrawableGL.makeCurrent(DrawableGL.java:110)
at org.lwjgl.opengl.Display.makeCurrent(Display.java:706)
at org.lwjgl.opengl.Display.makeCurrentAndSetSwapInterval(Display.java:1025)
at org.lwjgl.opengl.Display.setDisplayMode(Display.java:251)
at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:117)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)
Aug 21, 2014 6:35:05 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run
SEVERE: Display initialization failed. Cannot continue.
If so try setting the renderer to NullRenderer.
The core of the problem is lwjgl unable to have multiple opengl contexts at the same time.
So you probably start several Application instances that use lwjgl for rendering in the same jvm.
Wasn’t the problem after all. Turns out the AppState I was using to instance my server was experiencing raceway conditions dispite checks against it. Resulting in the server being instanced twice occasionally but not always.
Still not sure why the Appstate was being enabled multiple times so quickly but seperate threads. But as soon as I moved the server instancing code to the clients constructor instead all my null pointer errors went away.