Fix errors that crash the Java VM when a cursor is explicitly closed.

The java test suite now passes cleanly. refs #649