NullPointerException when trying to animate


I am having some issues trying to play an animation. The animation was created in Blender and the model was imported from a blend file and converted into a j3o. The animation does work when I go to view the model’s animation within the JME3 IDE.

The issue that I am having is the following exception:

at com.lhsalliance.aquatic.core.Main.btn_Start(
at com.lhsalliance.aquatic.core.Main$2.onAnalog(
at com.jme3.input.InputManager.invokeAnalogs(
at com.jme3.input.InputManager.invokeUpdateActions(
at com.jme3.input.InputManager.update(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

It looks like the problem is that it cannot get the animation control and is made null.
To view the current state of my Main class, click here. To view all of my code in GitHub, click here.

Thanks for the help!

Hi there,

Your stacktrace tells me that the nullpointer occures at line 374


Because the “this” is obviously not null, your control is null. Therefore your line before that

control = player.model.node.getControl(AnimControl.class);

You’re likely looking in the wrong place and would benefit from using this method

Also, be sure there isn’t 2 anim controls on your model by opening the .j3o in the scenecomposer.

Sometimes it will have 2, and you have to delete one.

For the record, even if ‘this’ were null, it would not cause an NPE on that line. Therefore, control is the only thing that could be null. ie: it works even if you were passing something else that might be null. (You’d get an NPE but in a different place.)