NoClassDefFoundError when using a CapsuleCollisionShape

Hi guys,



I’m trying to test basic physics including collision detection while learning JME3. I used the terrain tutorial as the basis and am trying to add collision detection to it. I’m basing this on the physics tutorial, so I need to create a CollisionShape to define the player. I’ve tried both CapsuleCollisionShape and CylinderCollisionShape, both throw the same error - NoClassDefFoundError. Please see stack trace below:



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

java.lang.NoClassDefFoundError: com/bulletphysics/collision/shapes/CollisionShape

at JME3Test.Helloworld.simpleInitApp(Helloworld.java:67)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:218)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:138)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: com.bulletphysics.collision.shapes.CollisionShape

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

… 5 more[/java]



And a code snippet:



[java]public static void main(String[] args) {

// TODO Auto-generated method stub



Helloworld helloJME3 = new Helloworld();

helloJME3.start();

}



private TerrainQuad terrain;

Material mat_terrain;

private CharacterControl player;

private Vector3f walkDirection = new Vector3f();

private BulletAppState bulletAppState;

Node terrainPhysicsNode;

private boolean left = false, right = false, up = false, down = false;



@Override

public void simpleInitApp() {

setUpKeys();

setUpLight();



CylinderCollisionShape capsuleShape = new CylinderCollisionShape(new Vector3f(2f,6f,2f));

player = new CharacterControl(capsuleShape, 0.05f);

player.setJumpSpeed(20);

player.setFallSpeed(30);

player.setGravity(30);

player.setPhysicsLocation(new Vector3f(0, 10, 0));



flyCam.setMoveSpeed(100);[/java]



I’ve just included the code I thought would be most relevent. Here is a sendspace link to the complete file.



Any help would be appreciated.

Slight update.



Found out I wasnt instantiating the BulletAppPhysics object or attaching to the stateManager. I did so, like in Tutorial 9, but it still doesnt work. The stack trace has changed slightly, however. I’ve commented out the other code so it doesnt setup any lights, keys, player objects or terrain. Does pretty much nothing actually. I even commented out the onAction and simpleUpdate events.



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

java.lang.NoClassDefFoundError: com/bulletphysics/collision/dispatch/CollisionWorld$ConvexResultCallback

at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:135)

at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:162)

at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:69)

at JME3Test.Helloworld.simpleInitApp(Helloworld.java:65)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:218)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:138)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: com.bulletphysics.collision.dispatch.CollisionWorld$ConvexResultCallback

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)[/java]

Are you sure you have the jbullet-library in your classpath?

1 Like

Thank you, that was it! Plus the vector math library. Well, at least it runs, now to uncomment my code and see if it actually works.