NullPointerException when running threads

5 replies [Last post]
Offline
Joined: 01/06/2011

Hey Jason, when I run a thread (same way as presented in lesson 6) I get this error:
 Exception in thread "Thread-6" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glClearColor(GL11.java:570)
at com.jme.renderer.lwjgl.LWJGLRenderer.setBackgroundColor(LWJGLRenderer.java:445)
at env3d.Env.advanceOneFrame(Env.java:658)
at env3d.Env.advanceOneFrame(Env.java:591)
at Simulator.oneStep(Simulator.java:61)
at Game$1.run(Game.java:77)
 
The simulation still continues to run, but I thought I'd give you a heads up.  This happened on both my Vista and XP systems.

Offline
Joined: 12/13/2010
Did you call

Did you call env.advanceOneFrame() inside the simulator thread?  One restriction when using threads is that opengl rendering must be done in a single thread.  The simulator must only perform non-rendering activities (like updating the location of objects).

Offline
Joined: 01/06/2011
Thanks, that was it exactly.

Thanks, that was it exactly.  I happened to encounter another error however (different thing, but I thought I might as well keep it in here).  It occurs when I use EnvTerrain:
5-Feb-2011 8:55:40 PM com.jme.scene.Node <init>
INFO: Node created.
5-Feb-2011 8:55:40 PM com.jme.scene.Node attachChild
INFO: Child "block" attached to this node "null"
5-Feb-2011 8:55:40 PM com.jme.system.lwjgl.LWJGLDisplaySystem <init>
INFO: LWJGL Display System created.
5-Feb-2011 8:55:40 PM com.jme.scene.Node <init>
INFO: Node created.
5-Feb-2011 8:55:40 PM com.jme.scene.Node attachChild
INFO: Child "block" attached to this node "null"
 
What I'm getting is the rendered terrain, but it's not being textured properly (it just shows up as white).  
 
Also, I'm not sure whether the setScale(double, double, double) method is intended to work only with image-based heightmaps, but I keep getting a NullPointerException when I use it.  Instead I'm just using the single parameter setScale method.

Offline
Joined: 01/06/2011
I just got another one as

I just got another one as well that popped up without modification of my code:
java.lang.UnsatisfiedLinkError:
...lwjgl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform (in java.lang.ClassLoader$NativeLibrary)
Stack trace:
java.lang.UnsatisfiedLinkError: C:\Users\TOSHIBA\Programming\Env3d\126 Framework\lwjgl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:82)
at org.lwjgl.Sys.<clinit>(Sys.java:99)
at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
at com.jme.system.lwjgl.LWJGLDisplaySystem.initDisplay(LWJGLDisplaySystem.java:418)
at com.jme.system.lwjgl.LWJGLDisplaySystem.createWindow(LWJGLDisplaySystem.java:143)
at env3d.Env.initSystem(Env.java:766)
at env3d.Env.<init>(Env.java:142)
at env3d.Env.<init>(Env.java:123)
at env3d.advanced.EnvAdvanced.<init>(EnvAdvanced.java:45)
at Game.play(Game.java:84)
at Game.main(Game.java:227)
 
 
The strange thing about that error message is that I'm not running an AMD machine - I'm running Intel (maybe an old error code since AMD had 64-bit before Intel)?
 
EDIT: For whatever reason it's doing that consistently now and I can't run it with terrain on.  As far as code I've written, the error comes from within:
env = new EnvAdvanced();
 
EDIT2: Closing BlueJ stops it from running the next time I start it up, but instead I'm getting a ConcurrentModificationException when I process my dead_creatures (done in the same simulation thread where they're passed to the creatures which add other creatures to the list).  That seems to then trigger the other error when I try to run it again.

Offline
Joined: 12/13/2010
In general, a concurrent

In general, a concurrent modification error has to do with 2 threads trying to modify a list at the same time, or attempting to modify a list while processing it using the enhanced for loop.  Try checking your code and see if you are doing either of these things.

Offline
Joined: 01/06/2011
That was the same error as

That was the same error as Monday.  Thanks for helping me sort through those.  I made the mistake of running the env.advanceOneFrame() call inside the new thread.
 
The white terrain came from me calling the wrong method (note: EnvTerrain.loadTexture() is not what you want to call, use EnvTerrain.setTexture() ).  The other error message that was popping up while in class and continued to pop up sort of magically disappeared.  It didn't prevent the program from running, but I'm not sure what was up with it.
 
Thanks for troubleshooting the issues in the lab!