NoSuchMethodError Exception when using BUI

Hey guys,



I got an error while running after I tried to add BUI to my game. This is the error:


Jun 1, 2007 11:02:29 PM com.jmex.bui.BRootNode draw
WARNING: com.jmex.bui.BDecoratedWindow@5d855f failed in render()
java.lang.NoSuchMethodError: com.jme.renderer.Renderer.getCurrentState(I)Lcom/jme/scene/state/RenderState;
   at com.jmex.bui.BComponent.applyDefaultStates(BComponent.java:67)
   at com.jmex.bui.border.LineBorder.render(LineBorder.java:56)
   at com.jmex.bui.BComponent.renderBorder(BComponent.java:751)
   at com.jmex.bui.BComponent.render(BComponent.java:541)
   at com.jmex.bui.BRootNode.draw(BRootNode.java:314)
   at com.jme.renderer.RenderQueue.renderOrthoBucket(Unknown Source)
   at com.jme.renderer.RenderQueue.renderBuckets(Unknown Source)
   at com.jme.renderer.Renderer.renderQueue(Unknown Source)
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(Unknown Source)
   at com.jmex.game.StandardGame.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)



The MenuState class extends BasicGameState, and the only part i have any code in is the constructor which is listed below:


public MenuState() {
      super("menu");
      InputHandler input = new InputHandler();
      PolledRootNode _root = new PolledRootNode(Timer.getTimer(), input);
      rootNode.attachChild(_root);
      //MouseInput.get().setCursorVisible(true); //This freezes the game?
      BStyleSheet style = null;
      try {
         InputStream stin = getClass().getClassLoader().getResourceAsStream("resources/gui/default.bss");
         style = new BStyleSheet(new InputStreamReader(stin),
               new BStyleSheet.DefaultResourceProvider());
      } catch (Exception e) {
         e.printStackTrace(System.err);
         System.exit(-1);
      }
      BWindow window;
      window = new BDecoratedWindow(style, null);
      BButton button = new BButton("Login");
      button.setTooltipText("Press this button to login.");
      button.setEnabled(true);
      window.setSize(200, 150);
      window.center();
      window.setEnabled(true);
      _root.addWindow(window);
   }



My main method is as follows:


   public static void main(String[] args) throws Exception {
      // Instantiate StandardGame
      StandardGame game = new StandardGame("Astronomy Domine");
      // Show settings screen
      GameSettingsPanel.prompt(game.getSettings());
      StaticGlobals.GAME_SETTINGS = game.getSettings();
      // Start StandardGame, it will block until it has initialized successfully, then return
      game.start();
      
      MenuState menuState = new MenuState();
      InGameState inGameState = new InGameState();
      // Add it to the manager
      GameStateManager.getInstance().attachChild(menuState);
      GameStateManager.getInstance().attachChild(inGameState);
      
      // Activate the game state
      menuState.setActive(true);
      //inGameState.setActive(true);
   }



Hopefully this isnt too much code to look at. I just wanted you guys to have a good picture so that you can diagnose the problem easier.

Thanks,
pip

Seems that the signature of the class is wrong. Have you updated from the CVS recently and recompiled jME? That should solve the problem

So the latest release of JME isnt compatible with the latest release of BUI?

yes, that's very likely

I downloaded the nightly build and replaced all the jar files, and still get the same error.

Well it seems that the BUI code is trying to access a method in jME that no longer exists. My recommendation would be to bring this issue to the BUI community.

The wierd thing is that I checked the source code for that part of BUI and the call it makes to JME and the function is there. Also, the BUI website http://www.samskivert.com/code/jme-bui/ says that discussions usually take place here so I kinda thought this was the community. I’ll send an email to the email listed on that page.

mmm  :? Unfortunately I do not have the BUI source code because I don't have svn in this computer… Maybe if you try to compile BUI yourself it would work.

I resolved it by using the latest build of JME and building the newest source from BUI's SVN. I had to make a a change to the build script so it would use the newest junit jar but it seems to work now. I only see a rectangle instead of a window and a button but at least its not throwing exceptions.

I now have a different exception, though this time its while retrieving the image. Its a NullPointerException so at first i thought the path was wrong but then i noticed it was pointing to this line in the BImage file:


_supportsNonPowerOfTwo = GLContext.getCapabilities().GL_ARB_texture_non_power_of_two;



The whole stack trace:


Exception in thread "main" java.lang.ExceptionInInitializerError
   at com.jmex.bui.BStyleSheet$DefaultResourceProvider.loadImage(BStyleSheet.java:172)
   at com.jmex.bui.BStyleSheet$BackgroundProperty.resolve(BStyleSheet.java:726)
   at com.jmex.bui.BStyleSheet.getProperty(BStyleSheet.java:385)
   at com.jmex.bui.BStyleSheet.findProperty(BStyleSheet.java:344)
   at com.jmex.bui.BStyleSheet.getBackground(BStyleSheet.java:267)
   at com.jmex.bui.BComponent.configureStyle(BComponent.java:789)
   at com.jmex.bui.BTextComponent.configureStyle(BTextComponent.java:115)
   at com.jmex.bui.BButton.configureStyle(BButton.java:208)
   at com.jmex.bui.BComponent.wasAdded(BComponent.java:756)
   at com.jmex.bui.BLabel.wasAdded(BLabel.java:155)
   at com.jmex.bui.BContainer$2.apply(BContainer.java:310)
   at com.jmex.bui.BContainer.applyOperation(BContainer.java:388)
   at com.jmex.bui.BContainer.wasAdded(BContainer.java:308)
   at com.jmex.bui.BWindow.setRootNode(BWindow.java:245)
   at com.jmex.bui.BRootNode.addWindow(BRootNode.java:109)
   at com.jmex.bui.BRootNode.addWindow(BRootNode.java:69)
   at game.engine.states.MenuState.<init>(MenuState.java:69)
   at game.engine.GameController.main(GameController.java:55)
Caused by: java.lang.NullPointerException
   at com.jmex.bui.BImage.<clinit>(BImage.java:384)
   ... 18 more



Is there any reason the getCapabilities method would return something that is null?

Yes, if it was happening outside of the GL context holding thread.

Its in a static block, but the initialization is in the main thread. All the code is the same as in the first post. Does that give you any clue into why this is happening?

in your case the main thread is not the opengl thread.

the opengl thread is the one started by StandardGame.

Yeh i just realized that. So does that mean i cant use BUI with standard game? or do i have to switch context?

you would have to make sure at least the first addWindow() call is made in the opengl thread.

you'll have to find a workaround. something quick & dirty like overriding initSystem() of StandardGame with an implementation that calls initSystem() and then calls new BImage() just to make sure the static initialization takes place in the opengl thread.



yeah, i know it#s dirty but i can't think of anything else

   public void initSystem(){
      
      super.initSystem();
      try {
         new BImage(new URL(""));
      } catch (MalformedURLException e) {
      } catch (IOException e) {
      }
   }



This did it. Thanks guys.

i did a quick search and it appears that that's the only place where such an access is made in BUI, so you prbably won't have to do any other workarounds like this.



it's still extremely ugly

I got other errors when i clicked the button :frowning:



Jun 2, 2007 2:00:02 PM com.jmex.bui.BContainer applyOperation
WARNING: Child operation choked[op=com.jmex.bui.BContainer$2@e14d81, child=com.jmex.bui.BButton@1a7789c].
java.lang.NullPointerException
   at org.lwjgl.opengl.GL11.glHint(GL11.java:1477)
   at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(Unknown Source)
   at com.jmex.bui.BImage$1.acquireTextures(BImage.java:371)
   at com.jmex.bui.BImage.acquireTexture(BImage.java:345)
   at com.jmex.bui.BImage.reference(BImage.java:310)
   at com.jmex.bui.background.ImageBackground.wasAdded(ImageBackground.java:145)
   at com.jmex.bui.BComponent.wasAdded(BComponent.java:761)
   at com.jmex.bui.BLabel.wasAdded(BLabel.java:155)
   at com.jmex.bui.BContainer$2.apply(BContainer.java:310)
   at com.jmex.bui.BContainer.applyOperation(BContainer.java:388)
   at com.jmex.bui.BContainer.wasAdded(BContainer.java:308)
   at com.jmex.bui.BWindow.setRootNode(BWindow.java:245)
   at com.jmex.bui.BRootNode.addWindow(BRootNode.java:109)
   at com.jmex.bui.BRootNode.addWindow(BRootNode.java:69)
   at game.engine.states.MenuState.<init>(MenuState.java:70)
   at game.engine.GameController.main(GameController.java:75)



Is there any better options for GUIs short of making my own?

FengGUI

In future releases of jME there will be improved mutlithreaded support so hopefully issues like this will magically go away.  :confused: