Updating terrainpage heightmap

I want to update my TerrainPage without having to construct a new TerrainPage object. I tried doing this through the following code:



       public void updateHeightMap( final int[] newMap ){
      // Change the heightmap data
      for( int x = 0; x < size; x++ ){
         for(int y = 0; y < size; y++  ){
            int i = x * size + y;
            page.setHeightMapValue(x, y, newMap[i]);
         }
      }
      page.updateFromHeightMap();
   }



but this gives me the following NullPointer stacktrace:


Exception in thread "builder" java.lang.NullPointerException
   at org.lwjgl.opengl.ARBBufferObject.glDeleteBuffersARB(ARBBufferObject.java:46)
   at com.jme.renderer.lwjgl.LWJGLRenderer.deleteVBO(Unknown Source)
   at com.jme.renderer.lwjgl.LWJGLRenderer.deleteVBO(Unknown Source)
   at com.jmex.terrain.TerrainBlock.updateFromHeightMap(Unknown Source)
   at com.jmex.terrain.TerrainPage.updateFromHeightMap(Unknown Source)
   at com.jmex.terrain.TerrainPage.updateFromHeightMap(Unknown Source)
   at com.jmex.terrain.TerrainPage.updateFromHeightMap(Unknown Source)
   at nl.tygron.simport.client.gui.map.SimMap.updateHeightMap(SimMap.java:165)
   at nl.tygron.simport.client.gui.map.MapSystem$3.run(MapSystem.java:438)



I'm not sure what this means and what to do about it. Can anyone explain this exception to me?

Thanks

You have to invoke this method from the OpenGL thread. That is the main thread that most of the jME stuff runs in…