jBox2d revolute joint creation error

I’m trying to integrate jBox2d into my game engine and I’ve been working on adding joints to it, however I’m coming across a weird error that seems to crop up as soon as I try to move a physics object after I’ve joined it with another:

Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 0
	at org.jbox2d.dynamics.Island.add(Island.java:577)

This exception occurs during a world step.

The code that I create the joint with is this:


public RevoluteJoint joinBodiesRevolute(Body a, Body b, Vec2 an){
        RevoluteJointDef rjd = new RevoluteJointDef();        
        rjd.initialize(a, b, new Vec2(2, 2));        
        rjd.enableMotor = true;
        rjd.motorSpeed = 100.0f;         
        rjd.lowerAngle = 1.0f;
        rjd.upperAngle = -1.0f;
        rjd.collideConnected = false;
        rjd.maxMotorTorque = 1.0f;        
        rjd.localAnchorA.set(a.getPosition());
        rjd.localAnchorB.set(b.getPosition());
        
        System.out.println(a + ", " + b);       
        
        RevoluteJoint j = (RevoluteJoint) gWorld.createJoint(rjd);
        
        return j;
    }

Am I doing something wrong? Thank you for any help.