Hello, I get a null pointer exception when receiving a collision event on an Android 3.1 device: java.lang.NullPointerException Exception thrown in Thread[GLThread 10,5,main]: at com.jme3.bullet.collision.PhysicsCollisionEvent.getNodeA(-1) at mygame.FlyingObjectsGame.collision(134) at com.jme3.bulletPhysicsSpace.distributedEvents(-1)
The problem is that getNodeA(), getNodeB(), getObjectA() and getobjectB() return null on Android but work fine on a Windows desktop.
Is there any workaround to avoid this problem on Android?
Thanks in advance for your help
You sure you use the latest version? Also, did you compare native bullet on desktop or jbullet?
Hi normen,
thanks for your reply. I am using:
– Product Version: jMonkeyEngine SDK 3.0beta
You’re right, I was using the non native version on the desktop.
Now that I use the native version on the desktop I also get the exception here. The application I am running is a modified version of the cannonBall (removing the wall) and making the ball hit the floor.
Do you know why it crashes with the native implementation? I am just adding a collision listener and accesing the nodes with getNodeA and getNodeB
My two colliding objects are a ball:
Geometry ball_geo = new Geometry(“ball”, sphere);
ball_geo.setMaterial(stone_mat);
rootNode.attachChild(ball_geo);
/** Position the cannon ball /
ball_geo.setLocalTranslation(cam.getLocation());
/* Make the ball physcial with a mass > 0.0f /
ball_phy = new RigidBodyControl(1f);
ball_name=ball_phy.toString();
//ball_phy=new GhostControl(new SphereCollisionShape(0.4f));
/* Add physical ball to physics space. /
ball_geo.addControl(ball_phy);
bulletAppState.getPhysicsSpace().add(ball_phy);
/* Accelerate the physcial ball to shoot it. /
ball_phy.setLinearVelocity(cam.getDirection().mult(25));
and a floor:
Geometry floor_geo = new Geometry(“Floor”, floor);
floor_geo.setMaterial(floor_mat);
floor_geo.setLocalTranslation(0, -0.1f, 0);
this.rootNode.attachChild(floor_geo);
/ Make the floor physical with mass 0.0f! */
floor_phy = new RigidBodyControl(0.0f);
floor_geo.addControl(floor_phy);
bulletAppState.getPhysicsSpace().add(floor_phy);
Thanks again for your help
Update the SDK. Help->Check for Updates
Normen, I updated the SDK as you said, restarted the SDK but I still have the problem.
Clean & build your project.
I also did it and no good news
java.lang.NullPointerException
at com.jme3.bullet.collision.PhysicsCollisionEvent.getNodeA(Unknown Source)
at mygame.Main.collision(Main.java:189)
at com.jme3.bullet.PhysicsSpace.distributeEvents(Unknown Source)
at com.jme3.bullet.BulletAppState.update(Unknown Source)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:249)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:255)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)
at java.lang.Thread.run(Thread.java:662)
I cannot reproduce this, for me collision callbacks work fine both with native bullet and jbullet… Do the getObjectA and getObjectB return anything? The NPE can only happen if they are null.
Normen,
getObjectA and getObjectB also return null
Thanks for your patience
Just in case this helps. These are the libraries that I am including in the project
artifactURI=null, type=1, property=${libs.jme3-libraries-physics-native.classpath}, object=Library[jme3-libraries-physics-native], broken=false, additional={}
artifactURI=null, type=1, property=${libs.jme3.classpath}, object=Library[jme3], broken=false, additional={}
artifactURI=null, type=1, property=${libs.jme3-libraries-lwjgl-minimum.classpath}, object=Library[jme3-libraries-lwjgl-minimum], broken=false, additional={}
artifactURI=null, type=1, property=${libs.jme3-libraries-oggvorbis.classpath}, object=Library[jme3-libraries-oggvorbis], broken=false, additional={}
Thanks
and this is the output of the execution before the crash. Maybe this provides some useful info
27-dic-2011 19:36:14 com.jme3.system.JmeSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta
27-dic-2011 19:36:14 com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: C:DocumentsNetBeansProjectsBasicGame
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglAbstractDisplay run
INFO: Using LWJGL 2.8.2
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglDisplay createContext
INFO: Selected display mode: 640 x 480 x 0 @0Hz
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: igdumdx32
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 8.15.10.2119
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Intel
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 2.1.0 - Build 8.15.10.2119
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: Intel® HD Graphics
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 1.20 - Intel Build 8.15.10.2119
27-dic-2011 19:36:14 com.jme3.system.lwjgl.LwjglTimer
INFO: Timer resolution: 1.000 ticks per second
27-dic-2011 19:36:14 com.jme3.renderer.lwjgl.LwjglRenderer initialize
INFO: Caps: [FrameBuffer, FrameBufferMRT, OpenGL20, OpenGL21, ARBprogram, GLSL100, GLSL110, GLSL120, VertexTextureFetch, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray]
27-dic-2011 19:36:14 com.jme3.asset.DesktopAssetManager
INFO: DesktopAssetManager created.
27-dic-2011 19:36:14 com.jme3.renderer.Camera
INFO: Camera created (W: 640, H: 480)
27-dic-2011 19:36:14 com.jme3.renderer.Camera
INFO: Camera created (W: 640, H: 480)
27-dic-2011 19:36:14 com.jme3.input.lwjgl.LwjglMouseInput initialize
INFO: Mouse created.
27-dic-2011 19:36:14 com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
27-dic-2011 19:36:14 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
27-dic-2011 19:36:14 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
27-dic-2011 19:36:14 com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
27-dic-2011 19:36:14 com.jme3.material.MaterialDef
INFO: Loaded material definition: Unshaded
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Gui Node)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
Bullet-Native: Initializing java classes
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (Floor) attached to this node (Root Node)
27-dic-2011 19:36:14 com.jme3.bullet.objects.infos.RigidBodyMotionState
INFO: Created MotionState 62f4c8
27-dic-2011 19:36:14 com.jme3.bullet.collision.shapes.BoxCollisionShape createShape
INFO: Created Shape 62f570
27-dic-2011 19:36:14 com.jme3.bullet.objects.PhysicsRigidBody rebuildRigidBody
INFO: Created RigidBody 62f5d0
27-dic-2011 19:36:14 com.jme3.bullet.collision.PhysicsCollisionObject initUserPointer
INFO: initUserPointer() objectId = 62f5d0
27-dic-2011 19:36:14 com.jme3.bullet.PhysicsSpace addRigidBody
INFO: Adding RigidBody 6.485.456 to physics space.
27-dic-2011 19:36:14 com.jme3.scene.Node detachChildAt
INFO: Gui Node (Node): Child removed.
27-dic-2011 19:36:14 com.jme3.scene.Node detachChildAt
INFO: Gui Node (Node): Child removed.
27-dic-2011 19:36:14 com.jme3.scene.Node detachAllChildren
INFO: Gui Node (Node): All children removed.
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Gui Node)
27-dic-2011 19:36:14 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (DebugShapeNode)
27-dic-2011 19:36:14 com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
INFO: Uniform m_VertexColor is not declared in shader [ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Misc/Unshaded.frag, defines, type=Fragment]].
27-dic-2011 19:36:19 com.jme3.scene.Node attachChild
INFO: Child (ball) attached to this node (Root Node)
27-dic-2011 19:36:19 com.jme3.bullet.objects.infos.RigidBodyMotionState
INFO: Created MotionState 62ff80
27-dic-2011 19:36:19 com.jme3.bullet.collision.shapes.SphereCollisionShape createShape
INFO: Created Shape 624bd0
27-dic-2011 19:36:19 com.jme3.bullet.objects.PhysicsRigidBody rebuildRigidBody
INFO: Created RigidBody 4c20d20
27-dic-2011 19:36:19 com.jme3.bullet.collision.PhysicsCollisionObject initUserPointer
INFO: initUserPointer() objectId = 4c20d20
27-dic-2011 19:36:19 com.jme3.bullet.PhysicsSpace addRigidBody
INFO: Adding RigidBody 79.826.208 to physics space.
27-dic-2011 19:36:19 com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (DebugShapeNode)
27-dic-2011 19:36:19 com.jme3.app.Application handleError
GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main.collision(Main.java:187)
at com.jme3.bullet.PhysicsSpace.distributeEvents(Unknown Source)
at com.jme3.bullet.BulletAppState.update(Unknown Source)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:249)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:255)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)
at java.lang.Thread.run(Thread.java:662)
27-dic-2011 19:36:19 com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
27-dic-2011 19:36:19 com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
27-dic-2011 19:36:19 com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
27-dic-2011 19:36:19 com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
In that stack trace the exception is in your own code (Main.java:187)
That`s because I do the following in the collision method (just to test getObjectA):
public void collision(PhysicsCollisionEvent event) {
185: PhysicsCollisionObject s1=(PhysicsCollisionObject) event.getObjectA();
186: PhysicsCollisionObject s2=(PhysicsCollisionObject) event.getObjectB();
187: s1.toString();
188: s2.toString();
}
line 187 is s1.toString() and the exception is because s1 is null. I have checked with the debugger that s1 and s2 are null
Normen, are we using the same native dll?
bulletjme.dll 1.618.991 bytes last modified October 22, ‎2011, ‏‎6:31:58
Thanks
If you updated the SDK it comes with the new binaries, maybe try deleting it once so you make sure its actually the version that comes with the current jME3 version.
Normen,
I removed jME3-bullet-natives.jar from the jmonkey lib directory and recompiled the project (clean and build) and run it and I observe the same behavior (null pointer on collision event). What libraries is it using if the natives ones were removed? It seems it doesn’t care whether the native libraries are present or not because the null pointer exception is raised anyway.
I don’t understand this behavior at all!
Thanks for helping out with this. BTW Help->check for updates returns “Your application is up to date!”
The natives are extracted automatically, if not to the run folder then the native is extracted to (home)/.jme3/(apphash), try deleting that.
@Momoko_Fan: Somehow the extraction doesn’t work well, we need to revise this.
As far as I can see when a clean build my project a jME3-bullet-natives.jar file is copied into myapp\dist\lib directory (I don’t know where this jar comes from). Then when I run my application a bulletjme.dll file is automatically extracted into my application main directory. This file’s modification date is ‎December 27‎ 2011, ‏‎21:06:36 and its size is 2.002.179 bytes.
Finally when the collision occurs, the exception is raised because getObjectA returns null.
Hm, the bullet dll for the stable version should be about 1.624.726 bytes… Any chance theres still some updates hanging? Whats the actual version number of the “jMonkeyEngine3 Library” plugin? (Tools->Plugins)
now I have the nightly update (just because I tried to get the latest updates)
Version: 3.0.0.8957 Source: jMonkeyEngine SDK Nightly
but before I had the stable update. Do I go back to the last stable update as I initially had?