Problems setting up the camera [Solved]

Hello i followed the 13th tutorial of the wiki to set the camera but i am having problems. The example works fine but if i copy the portion i need to my project it does not work, this is my code:


private Camera cam;
private DisplaySystem display;

public void setCamera(){
      try{
         display= DisplaySystem.getDisplaySystem();
      
         cam = display.getRenderer().createCamera(display.getWidth(),
            display.getHeight());
      } catch (JmeException e) {
         
         System.out.println("Could not create displaySystem");
         System.exit(1);
      }
      
      cam.setFrustumPerspective(45.0f, (float) display.getWidth()
            / (float) display.getHeight(), 1, 1000);
      Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
      Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
      Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
      Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
      /** Move our camera to a correct place and orientation. */
      cam.setFrame(loc, left, up, dir);
      /** Signal that we've changed our camera's location/frustum. */
      cam.update();
      /** Assign the camera to this renderer. */
      display.getRenderer().setCamera(cam);
      
      
      /** Create a basic input controller. */
      FirstPersonHandler firstPersonHandler = new FirstPersonHandler(cam);
      /** Signal to all key inputs they should work 10x faster. */
      firstPersonHandler.getKeyboardLookHandler().setActionSpeed(10f);
      firstPersonHandler.getMouseLookHandler().setActionSpeed(1f);
      input = firstPersonHandler;      
   }



And this is the error:


07-jul-2010 0:08:34 com.jme.renderer.AbstractCamera <init>
INFO: Camera created.
Exception in thread "main" java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:1960)
   at com.jme.scene.state.lwjgl.records.RendererRecord.switchMode(RendererRecord.java:57)
   at com.jme.renderer.lwjgl.LWJGLCamera.doFrustumChange(LWJGLCamera.java:194)
   at com.jme.renderer.lwjgl.LWJGLCamera.apply(LWJGLCamera.java:156)
   at com.jme.renderer.lwjgl.LWJGLRenderer.setCamera(LWJGLRenderer.java:245)
   at gamestates.GameState.setCamera(GameState.java:108)
   at gamestates.GameState.<init>(GameState.java:41)
   at main.Compas.main(Compas.java:21)



The problem becomes from this line:
display.getRenderer().setCamera(cam);

What could be the problem?



I solved the problem adding this to code:
GameTaskQueueManager.getManager () .update(new Callable<Void>() {
    public Void call() {
    display.getRenderer().setCamera(cam);
        return null;
    }
});
I read that the problem could come from the opengl thread and the java concurrency.